SOLVED

Re: Token Default=edit me Not Replaced

Go to solution
Isabelle_Kaleka
Level 2

Token Default=edit me Not Replaced

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Michael_Florin
Level 10

Re: Token Default=edit me Not Replaced

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

 

View solution in original post

2 REPLIES 2
Michael_Florin
Level 10

Re: Token Default=edit me Not Replaced

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

 

Isabelle_Kaleka
Level 2

Re: Token Default=edit me Not Replaced

Ah! Okay, thanks for the info.