SOLVED

Setting default value for a email script velocity token

Go to solution
Sophia_Sellars
Level 2

Setting default value for a email script velocity token

I have this email script that is working correctly: 

#set( $inTimeZone = $date.getTimeZone().getTimeZone('America/New_York') )

#set( $outTimeZone = $date.getTimeZone().getTimeZone('America/New_York') )

#set( $locale = $date.getLocale() )

#set( $myDate = $convert.parseDate($lead.End_Date_Formula__c,'yyyy-MM-dd',$locale,$inTimeZone) )

${date.format('EEEE, MMMM dd, yyyy',$myDate,$locale,$outTimeZone)}

 

 

the only thing left is that I want to set the default value, so if the lead.end_date_formula_C is blank, then I want "the end of the month" to appear instead. 

 

Is this on the right track? 

#if( ${lead.End_Date_Formula__c} == "" )

#set (
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Setting default value for a email script velocity token

If I want to set it to a phrase if it's empty, do I just put 

 

## End of the month

 

No, that would be a comment!

 

You would just put, literally

 

 

End of the month

 

 

In Velocity, anything not inside a #directive is considered to be plain output.

View solution in original post

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Setting default value for a email script velocity token

Please highlight your code using the syntax highlighter so it's readable (choose Java from the dropdown). Then we'll continue.

Sophia_Sellars
Level 2

Re: Setting default value for a email script velocity token

Sorry, I can't figure out what you're asking me to do. Can you explain?

SanfordWhiteman
Level 10 - Community Moderator

Re: Setting default value for a email script velocity token

Meaning click the Syntax Highlighter in the menu.

 

2020-04-03 16_48_30-Edit Message - Marketing Nation.png

Sophia_Sellars
Level 2

Re: Setting default value for a email script velocity token

Got it. I just updated it! Thank you for your help. 

SanfordWhiteman
Level 10 - Community Moderator

Re: Setting default value for a email script velocity token

 

#if( $lead.End_Date_Formula__c.isEmpty() )
## whatever you want to do if it's empty
#else
## the regular stuff
#end

 

Sophia_Sellars
Level 2

Re: Setting default value for a email script velocity token

If I want to set it to a phrase if it's empty, do I just put 

## End of the month

or do I need to write out something to show that it's text I would want to insert in replace of the token. 

 

Basically, if the salesforce field is blank, I want the email script token to insert the default language "the end of the month".  

SanfordWhiteman
Level 10 - Community Moderator

Re: Setting default value for a email script velocity token

If I want to set it to a phrase if it's empty, do I just put 

 

## End of the month

 

No, that would be a comment!

 

You would just put, literally

 

 

End of the month

 

 

In Velocity, anything not inside a #directive is considered to be plain output.