SOLVED

Email Script Help, extra space is displaying

Go to solution
Taylor_McCarty
Level 4

Email Script Help, extra space is displaying

I pieced this script together from some existing scripts in my instance and from some posts I found here and on blogs, but when I preview the email, the date ends up having a space at the end. Is this an issue with the script? Or is the script working correctly and the field value itself has the extra space the culprit?

#set( $dateOptions = { 
"fieldValue" : $o.Application_Deadline__c,
"formats" : {
"in" : "yyyy-MM-dd",
"out" : "MMMM d, yyyy"
},
"timezones" : {
"in" : "America/New_York",
"out" : "America/New_York"
},
"locale" : $date.getLocale()
} )
## ---- No need to change anything below this line! ----
#set( $dateOptions.timezones.in = $date.getTimeZone().getTimeZone($dateOptions.timezones.in) )
#set( $dateOptions.timezones.out = $date.getTimeZone().getTimeZone($dateOptions.timezones.out) )
#set( $inDate = $convert.parseDate($dateOptions.fieldValue, $dateOptions.formats.in, $dateOptions.locale, $dateOptions.timezones.in) )
${date.format($dateOptions.formats.out, $inDate, $dateOptions.locale, $dateOptions.timezones.out)}
#end
#end
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Email Script Help, extra space is displaying

Velocity is strictly space-preserving, so it sounds like the line break is actually what you're seeing as a space.

Try this instead:

${date.format($dateOptions.formats.out, $inDate, $dateOptions.locale, $dateOptions.timezones.out)}##

View solution in original post

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: Email Script Help, extra space is displaying

Please highlight the code (as Java, the closest to Velocity) using the Advanced Editor's Syntax Highlighter, then we'll continue.

Taylor_McCarty
Level 4

Re: Email Script Help, extra space is displaying

Updated and highlighted the code

SanfordWhiteman
Level 10 - Community Moderator

Re: Email Script Help, extra space is displaying

Velocity is strictly space-preserving, so it sounds like the line break is actually what you're seeing as a space.

Try this instead:

${date.format($dateOptions.formats.out, $inDate, $dateOptions.locale, $dateOptions.timezones.out)}##
Taylor_McCarty
Level 4

Re: Email Script Help, extra space is displaying

That worked! Thanks!