Stack Posted January 7, 2015 Share Posted January 7, 2015 I feel like this should be a really simple fix but I've been struggling with it all morning so I'm desperate... I have a business card I'm working on with 4 pages. The first 3 pages are variations of the front of the card, the last page is the back of the card, which is static. The 3 fronts are named accordingly: Phone+Fax - Used when both a phone and fax number are entered.Phone-or-Fax - Used when either a phone or fax number is entered (but not both).EmailOnly - Used when there is no phone or fax number entered. I've created a OnRecordStart rule and after tons of testing and fussing, this is the most recent JavaScript coding I've come up with: if (Field("Phone" && "Fax") !=="") { FusionPro.Composition.SetBodyPageUsage("Phone+Fax",true); FusionPro.Composition.SetBodyPageUsage("Phone-or-Fax",false); FusionPro.Composition.SetBodyPageUsage("EmailOnly",false); FusionPro.Composition.SetBodyPageUsage("Back",true); } if (Field("Phone" && "Fax") =="") { FusionPro.Composition.SetBodyPageUsage("Phone+Fax",false); FusionPro.Composition.SetBodyPageUsage("Phone-or-Fax",false); FusionPro.Composition.SetBodyPageUsage("EmailOnly",true); FusionPro.Composition.SetBodyPageUsage("Back",true); } else { FusionPro.Composition.SetBodyPageUsage("Phone+Fax",false); FusionPro.Composition.SetBodyPageUsage("Phone-or-Fax",true); FusionPro.Composition.SetBodyPageUsage("EmailOnly",false); FusionPro.Composition.SetBodyPageUsage("Back",true); } As it works right now, the Back page always returns and the EmailOnly page correctly returns if there's no phone AND fax number entered. However, if there's a phone and/or fax number present, it returns my Phone-or-Fax page, regardless if it's BOTH numbers or just one. I have test records that should return each page (again, Back always returns correctly) but none of them return the Phone+Fax page. Can anybody lend a hand with this? It seems like a simple fix but I can upload the files if it'll help. Thanks in advance! Quote Link to comment Share on other sites More sharing options...
ScottHillock Posted January 7, 2015 Share Posted January 7, 2015 Having the files would definitely be helpful, but here's something that should work. It's not the most elegant but it's pretty simplistic. FusionPro.Composition.SetBodyPageUsage("Phone+Fax",false); FusionPro.Composition.SetBodyPageUsage("Phone-or-Fax",false); FusionPro.Composition.SetBodyPageUsage("EmailOnly",false); var Var1 = 0; if (Field("Phone") !="" && Field("Fax") != "") { FusionPro.Composition.SetBodyPageUsage("Phone+Fax",true); Var1 = 1; } if (Field("Phone") =="" && Field("Fax") == "") { FusionPro.Composition.SetBodyPageUsage("EmailOnly",true); Var1 = 2; } if (Var1 == 0) { FusionPro.Composition.SetBodyPageUsage("EmailOnly",true); } Quote Link to comment Share on other sites More sharing options...
Stack Posted January 8, 2015 Author Share Posted January 8, 2015 Scott, thanks for your help! I had to tweak one line of your code but it got my template working exactly as needed. Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.