maven Posted November 20, 2008 Share Posted November 20, 2008 Can anyone show me how to write rule/s to accomplish the following? 1. Dear <_________>: If "salutation" is blank, return "firstname" else return "salutation" + space + "lastname" . . . If both "salutation" and "firstname" are blank, return the text "Colleague" 2. For: <_____>: If "company" is blank, return "salutation" + space + "firstname" + space + "middle initial" + space + "lastname" + space + "title" else return "company" (only put spaces in between fields if they contain data...) thanks for your time! margaret Link to comment Share on other sites More sharing options...
Alex Marshall Posted November 20, 2008 Share Posted November 20, 2008 Dont forget to check the box in the Rule editor for "Treat Return Strings As Tagged Text" 1. if(Field("salutation") =="") return Field("firstname") else return Field("salutation" )+"" + Field("lastname") else If (Field( "salutation" )+ Field("firstname" )== ""), return "Colleague"; 2. If(Field( "company" )== "") return Field("salutation") + "" + Field("firstname") + "" + Field("middle initial" )+ ""+ Field("lastname") + "" + Field("title") else return Field("company") Link to comment Share on other sites More sharing options...
DSweet Posted November 21, 2008 Share Posted November 21, 2008 Margaret, Try this for 1... if ((Field("salutation") == "") && (Field("firstname") == "")) { ...return "Colleague"; } else if ((Field("salutation") == "") && (Field("firstname") != "")) { ...return Field("firstname"); } else { ...return Field("salutation" )+ "." + Field("lastname"); } The only thing that you would need to worry about was if the lastname field was left empty with the salutation field filled in. ------- For the second one I would build up the salutation line piece by piece when "company" was blank. Like this... if (Field("company") != "") { ...return Field("company"); } else { ...var salOut = ""; ...if (Field("salutation") != "") ......salOut += Field("salutation"); ...if (Field("firstname") != "") ......salOut += "." + Field("firstname"); ...if (Field("middle initial") != "") ......salOut += "." + Field("middle initial"); ...if (Field("lastname") != "") ......salOut += "." + Field("lastname"); ...if (Field("title") != "") ......salOut += "." + Field("title"); ...return Trim(salOut); } Good Luck Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.