Jump to content

Text Formatting with On Record Start


Recommended Posts

I have a business card with a line of text that can include 3 different numbers (Desk Phone, Cell Phone, Fax). But obviously, users will not always have all three numbers. So i am trying to reformat the line of text based on which numbers they end up using.


Here are some of the possible number scenarios as an example (the "T:" , "M:" , "F:" , and "|") are static text whereas the phone numbers are the fields)



  • T: 123-123-1234
  • T: 123-123-1234 | M: 555-555-5555
  • T: 123-123-1234 | M: 555-555-5555 | F: 234-234-1123
  • M: 555-555-5555
  • M: 555-555-5555 | F: 234-234-1123
  • T: 123-123-1234 | F: 234-234-1123

You probably get the idea...



So what i have is different body pages with names that link up to each possible scenario (Phone Only, Cell Only, Phone and Fax, etc.) so that the body page SHOULD be decided based on which numbers they typed in.



Here is a look at my "on record start" rule code:




if (Field("Cell Phone" || "Fax") == "")


FusionPro.Composition.SetBodyPageUsage("Phone Only", true)


else if (Field("Fax") == "")


FusionPro.Composition.SetBodyPageUsage("Phone and Cell Phone", true)


else if (Field("Phone" || "Fax") == "")


FusionPro.Composition.SetBodyPageUsage("Cell Only", true)


else if (Field("Cell Phone") == "")


FusionPro.Composition.SetBodyPageUsage("PhoneFax", true)


else if (Field("Phone") == "")


FusionPro.Composition.SetBodyPageUsage("CellPhoneFax", true)




FusionPro.Composition.SetBodyPageUsage("All Three Phones", true)




I was able to get a handful of the pages to work but the other will just not work for me and I really am not sure why. Is there an easier way of doing this? I tried the "Suppress if containing empty variables" route but if you arent using all three numbers, the entire line is suppressed.



If you know an easier way of doing this or if you see some way to correct my code above, it would be much appreciated.



Thank you

Link to comment
Share on other sites


It looks like you have a space in fax.

FusionPro.Composition.SetBodyPageUsage("CellPhoneF ax", true)


You could use a rule similar to the example below so you wouldn't have all the body pages. I believe it returns the results you are looking for.

Modified from this thread.



 var numbers = 
    T: Field("Phone"),
    M: Field("Cell Phone"),
    F: Field("Fax"),


var result = [];
for (var label in numbers)
   if (numbers[label])
       result.push(label + ": " + numbers[label]);

var delim =  " " + '|' + " ";

return result.join(delim);

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.

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...