Hi there,
I'm currently using below token to get links in my email with modified date "2020-11-09". As I need to send out this edm every friday,. how can I change date from "2020-11-09" to today's date so I don't have to update the date in token every Friday
I tried tips from Sanfordwhiteman's blog but my coding skills are not great so couldn't do it https://blog.teknkl.com/velocity-days-and-weeks/
@SanfordWhiteman thanks in advance!
#set( $calNow = $date.getCalendar() )
<ul style="text-align: left;">
#foreach($emailAddress in $Report_20200214_cList)
#if ($emailAddress.modifiedDate == "2020-11-09")
<li style="text-align: left;color: #216E9B;"><a href="${emailAddress.rANDURL}" target="_blank" style="text-decoration: none; font-size: 12px; color: #007CC2;" class="mktNoTok">${emailAddress.dealership}</a></li>
#else
#end
#end
</ul>
Solved! Go to Solution.
Remember to always include all the common variables from that post. Otherwise, you won't be prepared to do date math.
This is one case where you don't have to cast the date-like String field (the one on your Custom Object) to a real Date object, you can just compare the stringified current date with the (already-stringified) stored date.
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/New_York") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
#set( $ISO8601DateTime = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateTimeWithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $ISO8601DateTimeWithMillisUTC = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" )
#set( $nowISO = $date.format($ISO8601DateOnly,$calNow,$defaultLocale,$defaultTimeZone) )
<ul style="text-align: left;">
#foreach($emailAddress in $Report_20200214_cList)
#if( $emailAddress.modifiedDate.equals($nowISO) )
<li style="text-align: left;color: #216E9B;"><a href="${emailAddress.rANDURL}" target="_blank" style="text-decoration: none; font-size: 12px; color: #007CC2;" class="mktNoTok">${emailAddress.dealership}</a></li>
#else
#end
#end
</ul>
Remember to always include all the common variables from that post. Otherwise, you won't be prepared to do date math.
This is one case where you don't have to cast the date-like String field (the one on your Custom Object) to a real Date object, you can just compare the stringified current date with the (already-stringified) stored date.
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/New_York") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
#set( $ISO8601DateTime = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateTimeWithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $ISO8601DateTimeWithMillisUTC = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" )
#set( $nowISO = $date.format($ISO8601DateOnly,$calNow,$defaultLocale,$defaultTimeZone) )
<ul style="text-align: left;">
#foreach($emailAddress in $Report_20200214_cList)
#if( $emailAddress.modifiedDate.equals($nowISO) )
<li style="text-align: left;color: #216E9B;"><a href="${emailAddress.rANDURL}" target="_blank" style="text-decoration: none; font-size: 12px; color: #007CC2;" class="mktNoTok">${emailAddress.dealership}</a></li>
#else
#end
#end
</ul>
Thanks a lot @SanfordWhiteman you are a savior. This works perfect!!