Jump to content

Rule Question.


Fletch

Recommended Posts

I'm inserting a variable into a static letter. The variable is the Salutation. It will go after the static word 'Dear'. There's is a field in my customers data file for 'Salutation', but only some of the records have data in that field. Most are blank. There is another field for 'First Name'. I need to create a rule that will use the 'Salutation' field only, unless blank, then it would use the 'First Name' instead. Is this possible?
Link to comment
Share on other sites

Easy peazy.

return (Field("Salutation") != "") ? "Dear " + Field("Salutation") : "Dear " + Field("First Name");

Of course, if some records contain nothing in either field, you would need to alter the code to account for a third, generic option...

Link to comment
Share on other sites

basically i have a CSv with firstname1 and firstname2 fields, and need to return "Dear firstname1 & firstname2,"

 

if there is no firstname2 the return

 

dear firstname,

return "Dear " + Field("firstname1") + (Field("firstname2") ? " & " + Field("firstname2") : "");

Link to comment
Share on other sites

Bummer the client has just changed the data and the rule now need to be more complex, but i cant get it right.

 

the data base has 2 firstname and 2 lastname columns

 

so if there is just one first name , return firstname + lastname

 

if there is firstname + firstname2 but no lastname2 - return firstname + & + firstname2 +lastname,

 

if firstnname, lastname, firstname2 lastname 2, return firstname + lastname + & + firstname2 + lastname2,

 

any suggestions???

Link to comment
Share on other sites

I finally figured it out!!

 

if (Field("Name1") && Field("Name2")&& Field("Lastname2"))
 return "Dear " + Field("Name1") + " " + Field("Lastname") + " & " + Field("Name2") + " " + Field("Lastname2") + ",";
else
if (Field("Name1") && Field("Name2") || Field("Lastname2" ))
 return "Dear " + Field("Name1") + " & " + Field("Name2") +  " " + Field("Lastname") + ",";
else 
return "Dear " + Field("Name1") + " " + Field("Lastname") + ",";

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...