SOLVED

Re: Token is empty mean need to hide entire row in my email

Go to solution
Muniyandi
Level 1

Token is empty mean need to hide entire row in my email

In my email when the token value is empty or blank, I want to hide a section in my HTML email.

could you please help me with how to achieve this?

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Token is empty mean need to hide entire row in my email

What language is interpreting the ternary operator in Method 2? Please test this on your side.

View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

Re: Token is empty mean need to hide entire row in my email

No need for the curly braces, and a String field on the Person can never be null or false.

 

To use a field only if it has at least one non-whitespace character, you only need:

 

#set( $firstName = $lead.FirstName )
#if( $firstName.trim().isEmpty() )
## Do nothing (the section will be hidden)
#else
<div>
<p>Hello $firstName,</p>
</div>
#end

 

It’s pretty unlikely for all-whitespace, non-empty values to make their way into First Name, but I suppose it’s possible.

 

 

View solution in original post

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: Token is empty mean need to hide entire row in my email

Well, “empty” and “blank” are the same thing. You probably meant null which is technically different in the database.

 

When you say “token”, do you actually mean the value of a Person field? Tokens — for example {{lead.tokens}} — are one way to output database values, but you should think in terms of the database itself. It’s confusing to talk about a token being empty because tokens can output default values even if the database field is empty.

 

 

 

reetusharmaGrz1
Level 2

Re: Token is empty mean need to hide entire row in my email

Hi @Muniyandi  If you're comfortable using Velocity Scripting (available in Marketo Email Script tokens), you can conditionally display content based on token values.

 

Example with first Name

#set( $firstName = ${lead.FirstName} )
#if( !$firstName || $firstName.trim() == "" )
## Do nothing (the section will be hidden)
#else
<div>
<p>Hello $firstName,</p>
</div>
#end

 

reetusharmaGrz1_0-1729599302945.png

 

Thanks

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Token is empty mean need to hide entire row in my email

What language is interpreting the ternary operator in Method 2? Please test this on your side.
SanfordWhiteman
Level 10 - Community Moderator

Re: Token is empty mean need to hide entire row in my email

No need for the curly braces, and a String field on the Person can never be null or false.

 

To use a field only if it has at least one non-whitespace character, you only need:

 

#set( $firstName = $lead.FirstName )
#if( $firstName.trim().isEmpty() )
## Do nothing (the section will be hidden)
#else
<div>
<p>Hello $firstName,</p>
</div>
#end

 

It’s pretty unlikely for all-whitespace, non-empty values to make their way into First Name, but I suppose it’s possible.