Hi, I have this code to make it so the Lead's first name is changed from all caps, what we have in the database, to just first letter cap. When there is no first name in the database, I would like to replace it to some default text, like Hi There, but it just ends up being blank.
I insert the token, which looks like this, with the default inputted: {{my.First Name First Letter Cap:default=Hi There}}
And when I check the preview, View By Default shows the subject as: {{my.First Name First Letter Cap}}. View By Person is just blank (when I select someone with no first name) or by there first name if they do have one.
This is the token code:
#set( $name = $lead.FirstName )
#if( !$name.isEmpty() )
${name.substring(0,1).toUpperCase()}${name.substring(1).toLowerCase()}
#end
Is there something I need to add so that the Default text is picked up?
Solved! Go to Solution.
That default version is not for script tokens. Just put the variant for empty first names in your script:
#set( $name = $lead.FirstName )
#if( !$name.isEmpty() )
${name.substring(0,1).toUpperCase()}${name.substring(1).toLowerCase()}
#else
There
#end
That default version is not for script tokens. Just put the variant for empty first names in your script:
#set( $name = $lead.FirstName )
#if( !$name.isEmpty() )
${name.substring(0,1).toUpperCase()}${name.substring(1).toLowerCase()}
#else
There
#end
Ah! Okay, thanks for the info.