ProspectComm Posted January 17, 2011 Share Posted January 17, 2011 Not very versed with java coding and need to make a rule that says if the data contains a "Salutation" to then return "Salutation" and "Lastname" but if there is not a "Salutation" to return just the "Firstname". Any help would be greatly appreciated. Rick Link to comment Share on other sites More sharing options...
esmith Posted January 17, 2011 Share Posted January 17, 2011 var result = Field("Firstname"); // replace with your first name field if (Field("Salutation") != "") { // replace with your salutation field result = Field("Salutation) + " " + Field("Lastname"); // replace both fields as necessary } return result; Link to comment Share on other sites More sharing options...
ProspectComm Posted January 18, 2011 Author Share Posted January 18, 2011 Thanks Eric, worked great. Just can't seem to wrap my head around the javascript coding! I'll have to buy a book or take a class. thanks again. Link to comment Share on other sites More sharing options...
esmith Posted January 18, 2011 Share Posted January 18, 2011 The code above basically reads: 1) set RESULT equal to (value of) field Firstname. 2) if field Salutation is not equal to nothing (i.e. it has a value) RESULT equals (value of) field Salutation plus a space plus (value of) field Lastname 3) return value of RESULT While a book will help you, I would suggest googling "javascript" with whatever it is you want to do first. It's more specific and cheaper! There are several sites that explain scripting to a new user. That's pretty much how I learned and if there's anything more complicated that a web page can show me, I ask on the forums. Good luck. Link to comment Share on other sites More sharing options...
Dan Korn Posted January 19, 2011 Share Posted January 19, 2011 Alternately: if (Field("Salutation")) return Field("Salutation) + " " + Field("Lastname"); //else return Field("Firstname"); Or even: return Field("Salutation") ? Field("Salutation) + " " + Field("Lastname") : Field("Firstname");Or, getting really tricky: return Field("Salutation") && Field("Salutation) + " " + Field("Lastname") || Field("Firstname"); Link to comment Share on other sites More sharing options...
ProspectComm Posted January 19, 2011 Author Share Posted January 19, 2011 Thanks Dan. There seems to be quite few different combinations to accomplish my question. Thanks again Rick Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.