Craig Posted April 18, 2012 Share Posted April 18, 2012 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 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(" • "); 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! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.