PDA

View Full Version : No first name rule?


Tattoued
April 10th, 2012, 09:24 AM
This is probably a REALLY easy formula, but I'm on overload right now, and code is way over my head for the most part, AND I don't very often have the need to create many rules... your help would be SO much appreciated!

I have a field called First Name. Some of the names have only an initial. The statement where the variable data will be placed is:

">>First Name<<, you don't need to travel to Pinehurst to play an authentic Donald Ross Golf Course!"

I'd like to create a rule where if the name is an initial only, remove the comma and space and make the lower case y an upper case Y and just forego the name altogether.

I'm trying, but I just can't seem to make it work and I HAVE to get this job out today! HELP PLEASE!:eek:

step
April 10th, 2012, 09:30 AM
return (Field("First Name").length >1) ? Field("First Name") + ", you don't need to travel to Pinehurst to play an authentic Donald Ross Golf Course!" : "You don't need to travel to Pinehurst to play an authentic Donald Ross Golf Course!";

Tattoued
April 10th, 2012, 09:45 AM
That's it? *sigh* I don't know why I can't "get" code... Thank you. Um... how would I put in a carriage return to split the sentence at the end of "Pinehurst"?
Or maybe I should call it a line break.

step
April 10th, 2012, 10:59 AM
You could do that one of two ways. You could code it into the existing rule using a break tag ("<br>"). You just need to make sure you have the check box checked to "Treat returned strings as tagged text" in the Rule Editor.


return (Field("First Name").length >1) ? Field("First Name") + ", you don't need to travel to Pinehurst<br> to play an authentic Donald Ross Golf Course!" : "You don't need to travel to Pinehurst<br> to play an authentic Donald Ross Golf Course!";


Or you could edit the code to just only return the first name and the "y" and handle the rest of the sentence and the line spacing in the text editor window.


return (Field("First Name").length >1) ? Field("First Name") + ", y" : "Y";


Then your text editor would like this:

Rule("FirstNameRule")ou don't need to travel to Pinehurst
to play an authentic Donald Ross Golf Course!

Tattoued
April 10th, 2012, 11:25 AM
Excellent! That worked beautifully! Thank you so much!