Hi there,
I was referencing this thread: Conditional First Name Token
#if (${lead.FirstName} == "[Not Provided]")
there
#else
${lead.FirstName},
#end
I have built the above but am struggling to pull in a value. We have leads that have a first name of [Not Provided], and we'd like to say if we identify the first name as such, fill in "there" as the value, if not identified as [Not Provided] use the value that lives in the field.
Solved! Go to Solution.
The code looks fine, though you don't need the curly braces and I recommend removing them (see Velocity ${formal.notation} invites syntax errors: use it wisely).
The code looks fine, though you don't need the curly braces and I recommend removing them (see Velocity ${formal.notation} invites syntax errors: use it wisely).
Removed the curly brackets and it worked!
Thank you!
It now correctly pulls in the "there" when "[Not Provided]" is in the first name field, as well as when there is a value in the first name field such as "Matilda." I'm now coming across an issue when the first name field is blank, that it's not pulling in the token default value. Any suggestions there?
Thanks for all your help!
Went and tested -- doesn't look like we can pull in that default value. Rewrote the script to include blank values. I tested and it works. Script is as follows:
#if ($lead.FirstName == "[Not Provided]")
there
#elseif ($lead.FirstName == "")
there
#else
$lead.FirstName
#end
Bit repetitive, I'd do this:
#if( $lead.FirstName.equals("[Not Defined]") || $lead.FirstName.isEmpty() )
there
#else
$lead.FirstName
#end