View Single Post
  #1  
Old May 22nd, 2018, 10:40 AM
gdellaiera gdellaiera is offline
Regular Contributor
 
Join Date: Nov 2016
Posts: 78
Default Switching pages with on record start

I am trying to create a banner with a few fields and some size changes based upon one of the fields.

I have 3 sizes for banners (18x12, 60x30, 72x36) based upon the number of years selected
1-5 = 18x12
10-15 = 18x12
20-25 = 60x30
30+ = 72x36

With 3 layouts for the background
Style 1
Style 2
Style 3

The field for "Years of service" is entered in manually while the background is based on a pick list of the 3 styles.

I believe that OnRecordStart would be my best bet for this, but I'm not getting the result I was hoping for.

I have set all pages to "Body, unused" and then I get no records to show. Originally I had all pages set to "Body" and each page displayed, which was not what I was looking for either.

I couldn't find anything that was similar enough for me to build off of on the forum yet, so I decided to post my javascript here and maybe someone would be able to find out what I am missing.

Thanks for the look and any and all help!


var Background = Field("Background");

if (Field("Years of Service") >=1 && Field("Years of Service")<= 5) + Field("Background") == "Style 1";
return ("Style 1 18x12");


if (Field("Years of Service") >=10 && Field("Years of Service")<= 15) + Field("Background") == "Style 1";
return ("Style 1 18x12");


if (Field("Years of Service") >=20 && Field("Years of Service")<= 25) + Field("Background") == "Style 1";
return ("Style 1 60x30");


if (Field("Years of Service") >=30 + (Field("Background") == "Style 1"));
return ("Style 1 72x36");


if (Field("Years of Service") >=1 && Field("Years of Service")<= 5) + Field("Background") == "Style 2";
return ("Style 1 18x12");


if (Field("Years of Service") >=10 && Field("Years of Service")<= 15) + Field("Background") == "Style 2";
return ("Style 2 18x12");


if (Field("Years of Service") >=20 && Field("Years of Service")<= 25) + Field("Background") == "Style 2";
return ("Style 2 60x30");


if (Field("Years of Service") >=30 + (Field("Background") == "Style 2"));
return ("Style 2 72x36");


if (Field("Years of Service") >=1 && Field("Years of Service")<= 5) + Field("Background") == "Style 3";
return ("Style 3 18x12");


if (Field("Years of Service") >=10 && Field("Years of Service")<= 15) + Field("Background") == "Style 3";
return ("Style 3 18x12");


if (Field("Years of Service") >=20 && Field("Years of Service")<= 25) + Field("Background") == "Style 3";
return ("Style 3 60x30");


if (Field("Years of Service") >=30 + (Field("Background") == "Style 3"));
return ("Style 3 72x36");



switch(Background) {

case "Style 1 18x12":
FusionPro.Composition.SetBodyPageUsage("Style 1 18x12",true);
FusionPro.Composition.SetBodyPageUsage("Style 1 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 72x36",false);
break;

case "Style 1 60x30":
FusionPro.Composition.SetBodyPageUsage("Style 1 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 60x30",true);
FusionPro.Composition.SetBodyPageUsage("Style 1 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 72x36",false);
break;

case "Style 1 72x36":
FusionPro.Composition.SetBodyPageUsage("Style 1 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 72x36",true);
FusionPro.Composition.SetBodyPageUsage("Style 2 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 72x36",false);
break;

case "Style 2 18x12":
FusionPro.Composition.SetBodyPageUsage("Style 1 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 18x12",true);
FusionPro.Composition.SetBodyPageUsage("Style 2 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 72x36",false);
break;

case "Style 2 60x30":
FusionPro.Composition.SetBodyPageUsage("Style 1 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 60x30",true);
FusionPro.Composition.SetBodyPageUsage("Style 2 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 72x36",false);
break;

case "Style 2 72x36":
FusionPro.Composition.SetBodyPageUsage("Style 1 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 72x36",true);
FusionPro.Composition.SetBodyPageUsage("Style 3 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 72x36",false);
break;

case "Style 3 18x12":
FusionPro.Composition.SetBodyPageUsage("Style 1 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 18x12",true);
FusionPro.Composition.SetBodyPageUsage("Style 3 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 72x36",false);
break;

case "Style 3 60x30":
FusionPro.Composition.SetBodyPageUsage("Style 1 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 60x30",true);
FusionPro.Composition.SetBodyPageUsage("Style 3 72x36",false);
break;

case "Style 3 72x36":
FusionPro.Composition.SetBodyPageUsage("Style 1 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 1 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 2 72x36",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 18x12",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 60x30",false);
FusionPro.Composition.SetBodyPageUsage("Style 3 72x36",true);
break;


}
Reply With Quote