wellers_97 Posted December 13, 2017 Posted December 13, 2017 We have a variable letter that we are setting up in fusion pro. On one page there is an agreement summary and it lists the Optional Coverage that they have. There are 24 different options (fields). What I'm trying to achieve is that if fields are used there will be a hyphen between them but it will drop out if not. Example: Option1 - Option2 - Option3 - Option 4 I started with this which works but I'm sure there is a much easier way than doing this for each option? if ((Field("optional1") != "") && (Field("optional2") != "")) return Field("optional1") + " - " + Field("optional2"); else if ((Field("optional1") != "") && (Field("optional2") == "")) return Field("optional1"); else return ""; Quote
kjacobson Posted December 13, 2017 Posted December 13, 2017 Give this a try var listOptions = []; //declare array for (i=1;i<=24;i++) { //setup loop to cycle through optional fields var option = Field("optional"+i); if (option != "") { //if the optional field is not blank then add to array listOptions.push(option); } } return listOptions.join(" - "); //list the array values separated by - Quote
wellers_97 Posted December 13, 2017 Author Posted December 13, 2017 Give this a try var listOptions = []; //declare array for (i=1;i<=24;i++) { //setup loop to cycle through optional fields var option = Field("optional"+i); if (option != "") { //if the optional field is not blank then add to array listOptions.push(option); } } return listOptions.join(" - "); //list the array values separated by - Worked perfectly! Thank YOU! Quote
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.