Jump to content

Recommended Posts

Posted

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 "";

Posted

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 -

Posted
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!

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