Setting default value for a email script velocity token | Community
Skip to main content
Sophia_Sellars
Level 2
April 3, 2020
Solved

Setting default value for a email script velocity token

  • April 3, 2020
  • 1 reply
  • 4726 views

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 (
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

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


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.

1 reply

SanfordWhiteman
Level 10
April 3, 2020

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
April 3, 2020

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

SanfordWhiteman
Level 10
April 3, 2020

Meaning click the Syntax Highlighter in the menu.