Fletch Posted October 27, 2009 Share Posted October 27, 2009 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 More sharing options...
esmith Posted October 27, 2009 Share Posted October 27, 2009 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 More sharing options...
Fletch Posted October 27, 2009 Author Share Posted October 27, 2009 You rock! Thanks! Link to comment Share on other sites More sharing options...
Dan Korn Posted October 27, 2009 Share Posted October 27, 2009 return "Dear " + (Field("Salutation") || Field("First Name")); Link to comment Share on other sites More sharing options...
aaronsupremeworks.com Posted October 29, 2009 Share Posted October 29, 2009 I need to use something like tis and have tried to modify the examples given but with out much luck. 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, Link to comment Share on other sites More sharing options...
Dan Korn Posted October 29, 2009 Share Posted October 29, 2009 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 More sharing options...
aaronsupremeworks.com Posted October 29, 2009 Share Posted October 29, 2009 Awesome.. I knew there had to be a simpler way... thanks Dan! Link to comment Share on other sites More sharing options...
aaronsupremeworks.com Posted October 30, 2009 Share Posted October 30, 2009 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 More sharing options...
aaronsupremeworks.com Posted October 30, 2009 Share Posted October 30, 2009 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 More sharing options...
esmith Posted November 2, 2009 Share Posted November 2, 2009 return "Dear " + Field("firstname1") + (Field("firstname2") ? " & " + Field("firstname2") : ""); Took me a few minutes to figure out the logic, but this is why I like to go back and read old posts. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.