MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (
-   The JavaScript Library (
-   -   Switching pages with on record start (

gdellaiera May 29th, 2018 07:05 AM

Re: Switching pages with on record start
1 Attachment(s)
I've added my data sheet. There are 4 variables: FirstName, LastName, Years of Service & Style. Not too much as these is very little information needed from the customer.

I'm going to read more about the switch and try to figure out where I am getting lost. Thanks again for all of the help!

gdellaiera June 4th, 2018 11:02 AM

Re: Switching pages with on record start

Originally Posted by step (Post 21181)
Both of those variables are set to the same value. Is that intentional?

I don't think that will work. If I'm understanding correctly, Gdellaiera is trying to determine which page to use here based on the "Years of Service" field and appending the style to the end of the string. So the correct syntax would be:

 * When the vale of the "Years of Service" field is between 10-15, the
 * page size should be 18x12 regardless of the style selected in the
 * "Background" field. So set the `page` variable to the appropriate size
 * and append the style to the end to dynamically cover all three styles.
if (Field("Years of Service") >=10 && Field("Years of Service")<= 15) {
  var page = "18x12 " + Field("Background");

I think a better way to accomplish this task would be:

// Get the "Years of Service" value and cast it as an integer for comparisons.
// Default the value to `1` when the field is empty.
var yearsOfService = Int(Field("Years of Service")) || 1;
// Get the style value from the "Background" field.
// Default to `Style 1`.
var background = Field("Background") || 'Style 1';
// Use a switch statement to determine which page size we should be using. We'll
// set the `size` variable to the first expression that evaluates to `true`.
switch (true) {
  // Check to see if the `yearsOfService` is 15 or less. If it is, we can set the
  // size to 18x12 and none of the other expressions in this `switch` will be evaluated.
  case yearsOfService <= 15: size = '18x12'; break;
  // If the `yearsOfService` is more than 15, we will check to see if the
  // `yearsOfService` field is 25 or less. If it is, set the size to 60x30.
  case yearsOfService <= 25: size = '60x30'; break;
  // If neither of the two previous cases were true, that means the `yearsOfService`
  // is greater than 25, so we can set the size to 72x36.
  default: size = '72x36';
// Since you've already set all of the body pages to `false`, you only need to
// enable the correct page.
FusionPro.Composition.SetBodyPageUsage(background + " " + size, true);

Can I ask one question here: Where is 'size' coming from? There is no variable in the document named size (or rule) and the only reference to any number is in the page name.

All times are GMT -7. The time now is 02:53 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.