Jump to content

Need help!


Craig

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...