Natea11 Posted November 16, 2012 Share Posted November 16, 2012 I'm looking for a fusion pro rule that will automatically position contact input from three fields four different ways. I imagine this would be achieved through a "if, result" scenario. Variable fields are "phone" (required), "fax" (optional) and "cell" (optional) presented in a data pattern as such (###) ###-####. Here's the if, result scenario. 1. If just the "phone" field has content then it's alone on one line and will appear as " t (###) ###-#### " 2. If the "phone" and "fax" are supplied the result will be " t (###) ###-#### | f (###) ###-#### " all on one line. 3. If "phone" and "cell" the result is " t (###) ###-#### | c (###) ###-#### " 4. The last scenario is if "phone" , "fax" and "cell" are supplied the result is " t (###) ###-#### | f (###) ###-#### <br> or hard return and c (###) ###-#### " so telephone and fax are on one line and the cell gets placed on the line below. Here's what I have so far. It's return the phone, but that's all. And I don't think there's any data pattern. if (Field("Fax") == "") and (Field("Cell") == ""); // Both Fax and Cell are empty return ("p " + Field("Phone")); // returns just the Phone # } else if ([Field("Fax") !== "") and (Field("Cell") == ""); // Fax is not empty and Cell is empty return ("p" + Field("Phone")" | " "f " + Field("Fax")"<br>"); // returns Phone number & Fax }else if (Field("Fax") == "") and (Field("Cell") !== ""); // Fax is empty and Cell is not empty return ("p" + Field("Phone")" | " "c " + Field("Cell")"<br>"); // returns Phone number & Cell } else // Last default resort, all fields contain something so you need the last scenario... return ("p " + Field("Phone")" | " "f" + Field("Fax")"<br>" "c " + Field("Cell")"<br>"); // returns all the itemsbcards_onesided.zip Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted November 16, 2012 Share Posted November 16, 2012 Try this: var labels = { p: Field("Phone"), f: Field("Fax"), c: Field("Cell"), }; var result = []; for (var l in labels) { if (labels[l]) result.push(l + " " + labels[l]); } return [result.slice(0,2).join(" | "),result[2]].filter(Boolean).join("<br>\n"); Quote Link to comment Share on other sites More sharing options...
Natea11 Posted November 19, 2012 Author Share Posted November 19, 2012 Dan you're a rockstar. Worked perfectly. Thanks 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.