Craig Posted April 18, 2012 Share Posted April 18, 2012 (edited) I am trying to create a rule that will compare 2 fields and if both fields exist, a bullet will be returned between them. If only one field exists there is no bullet. Here is where I am at... if (Field("2nd Email")&&(Field("Cottage Name")) return NormalizeEntities(Field("2nd Email")) " • " + NormalizeEntities(Field("Cottage Name")); //else return "" + NormalizeEntities(Field("Cottage Name")); So my outcome would be bob@abc.com • Bobs House or bob@abc.com or Bobs House Any help would be GREATLY appreciated Edited April 18, 2012 by Craig Quote Link to comment Share on other sites More sharing options...
step Posted April 18, 2012 Share Posted April 18, 2012 You could write it the way you have with if/else statements: var result = ""; if (Field("2nd Email") != "" && Field("Cottage Name") != ""){ result = NormalizeEntities(Field("2nd Email")) " • " + NormalizeEntities(Field("Cottage Name")); } else if (Field("2nd Email") != ""){ result = NormalizeEntities(Field("2nd Email")); } else if (Field("Cottage Name") != ""){ result = NormalizeEntities(Field("Cottage Name")); } return result; or you could simplify the code by using an array: var s = NormalizeEntities(Field("2nd Email")); var f = NormalizeEntities(Field("Cottage Name"))"; var result = []; (s != "") ? result.push(s) : "" ; (f != "") ? result.push(f) : "" ; return result.join(" • "); Quote Link to comment Share on other sites More sharing options...
Craig Posted April 18, 2012 Author Share Posted April 18, 2012 Thanks! Guess I looked like a boob! 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.