web2print Posted February 5, 2018 Share Posted February 5, 2018 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-1234T: 123-123-1234 | M: 555-555-5555T: 123-123-1234 | M: 555-555-5555 | F: 234-234-1123M: 555-555-5555M: 555-555-5555 | F: 234-234-1123T: 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) } else { 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 Quote Link to comment Share on other sites More sharing options...
Leosmith Posted February 6, 2018 Share Posted February 6, 2018 Hi, 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. http://forums.pti.com/showthread.php?t=4389&highlight=join+phone 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); Quote Link to comment Share on other sites More sharing options...
web2print Posted February 6, 2018 Author Share Posted February 6, 2018 Worked great! Thank you 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.