#1
|
|||
|
|||
![]()
Eric has been kind enough to help me work out the following age based code and I have to say it works brilliantly to turn on and off the back pages only for printing.
My question is how would I tell fusion to turn on and off both a front page and a back page. I am a noob and just can't get it to work. Below is the code that works perfect Code that works: // OnRecordStart Date.prototype.YearsBetween = function(){ var intMilYear = 365.23 * 24 * 60 * 60 * 1000; var intMilDif = arguments[0] - this; var intYears = Math.floor(intMilDif/intMilYear); return intYears; } var dob = new Date(Field("birthday")); // YOUR FIELD in a standard date format var today = new Date(); var yearsBetween = dob.YearsBetween(today); // Turn on age related backs for specific record (Pages named A,B,C,D and set to Unused) if (yearsBetween <=16) FusionPro.Composition.SetBodyPageUsage("BackA",tru e); else if (yearsBetween <= 40) FusionPro.Composition.SetBodyPageUsage("BackB",tru e); else if (yearsBetween <= 60) FusionPro.Composition.SetBodyPageUsage("BackC",tru e); else FusionPro.Composition.SetBodyPageUsage("BackD",tru e); What I need help with in red // OnRecordStart Date.prototype.YearsBetween = function(){ var intMilYear = 365.23 * 24 * 60 * 60 * 1000; var intMilDif = arguments[0] - this; var intYears = Math.floor(intMilDif/intMilYear); return intYears; } var dob = new Date(Field("birthday")); // YOUR FIELD in a standard date format var today = new Date(); var yearsBetween = dob.YearsBetween(today); // Turn on age related backs for specific record (Pages named A,B,C,D and set to Unused) if (yearsBetween <=16) FusionPro.Composition.SetBodyPageUsage("BackA",tru e) + FusionPro.Composition.SetBodyPageUsage("FrontA",tr ue); else if (yearsBetween <= 40) FusionPro.Composition.SetBodyPageUsage("BackB",tru e) + FusionPro.Composition.SetBodyPageUsage("FrontB",tr ue); ; else if (yearsBetween <= 60) FusionPro.Composition.SetBodyPageUsage("BackC",tru e)+ FusionPro.Composition.SetBodyPageUsage("FrontC",tr ue); ; else FusionPro.Composition.SetBodyPageUsage("BackD",tru e) + FusionPro.Composition.SetBodyPageUsage("FrontD",tr ue); ; Any help would be great. |
#2
|
|||
|
|||
![]()
My bad (sort of). I kept all the IF statements as one-liners since my example was only returning a single result per condition. In your case, you want to run 2+ commands so you need to place them on separate lines inside curly brackets "{}" as follows:
Code:
// Turn on age related backs for specific record (Pages named A,B,C,D and set to Unused) if (yearsBetween <=16) { FusionPro.Composition.SetBodyPageUsage("BackA",true); FusionPro.Composition.SetBodyPageUsage("FrontA",true); } else if (yearsBetween <= 40) { FusionPro.Composition.SetBodyPageUsage("BackB",true); FusionPro.Composition.SetBodyPageUsage("FrontB",true); } else if (yearsBetween <= 60) { FusionPro.Composition.SetBodyPageUsage("BackC",true); FusionPro.Composition.SetBodyPageUsage("FrontC",true); } else { FusionPro.Composition.SetBodyPageUsage("BackD",true); FusionPro.Composition.SetBodyPageUsage("FrontD",true); } |
#3
|
|||
|
|||
![]()
Thanks mate, your help is greatly appreciated.
|
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|