SOLVED

First Name Email Script Token

Go to solution

First Name Email Script Token

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.

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: First Name Email Script Token

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).

  • Do you have First Name checked off in the tree on the right-hand-side of Script Editor?
  • What do you see if you simply output $lead.FirstName?
  • Are you sure the case matches on both sides?
  • Are you testing with a real email, not Send Sample?

View solution in original post

6 REPLIES 6
Level 10 - Champion Alumni

Re: First Name Email Script Token

Re: First Name Email Script Token

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).

  • Do you have First Name checked off in the tree on the right-hand-side of Script Editor?
  • What do you see if you simply output $lead.FirstName?
  • Are you sure the case matches on both sides?
  • Are you testing with a real email, not Send Sample?

View solution in original post

Re: First Name Email Script Token

Removed the curly brackets and it worked!

Thank you!

Re: First Name Email Script Token

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!

Re: First Name Email Script Token

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

Re: First Name Email Script Token

Bit repetitive, I'd do this:

#if( $lead.FirstName.equals("[Not Defined]") || $lead.FirstName.isEmpty() )

there

#else

$lead.FirstName

#end