View Full Version : I'm Having Trouble Complex Salutation Line
maven
November 20th, 2008, 12:26 PM
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
Alex Marshall
November 20th, 2008, 12:42 PM
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")
DSweet
November 21st, 2008, 06:34 AM
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 ;)
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.