Jump to content

Issue with OnRecordStart / SetBodyPageUsage


Stack

Recommended Posts

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:

 

  1. Phone+Fax - Used when both a phone and fax number are entered.
  2. Phone-or-Fax - Used when either a phone or fax number is entered (but not both).
  3. 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!

Link to comment
Share on other sites

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);
}


Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...