Hi there,
We are experiencing an issue with email script tokens in our emails. We are pulling date information from Salesforce opportunity records and using email script tokens to populate the dates in renewal notification emails to our customers. The dates are pulling in and formatted correctly upon send. However, the dates that render in the emails are 5 days behind the actual dates on the opportunity in Salesforce (e.g. Salesforce Opportunity Date Field=12/05/2020 & Marketo email token=November 30, 2020) This is also happening with other date fields populated in the email body from a Salesforce opportunity. Why is this happening and how do to we fix this?
Here is the script I am using to format the date properly. I am guessing there is something incorrectly coded in this script, but I cannot determine which line of code might be changing the date results. Any help is very much appreciated!
#set($RenewalDate = $date.format("yyyy-MM-dd", ${OpportunityList.get(0).Renewal_Date__c}))
#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 = "MM-dd-yyyy" )
#set( $ISO8601DateTime = "MM-dd-yyyy'T'HH:mm:ss" )
#set( $ISO8601DateTimeWithSpace = "MM-dd-yyyy HH:mm:ss" )
#set( $ISO8601DateTimeWithMillisUTC = "MM-dd-yyyy'T'HH:mm:ss.SSSZ" )
$calNow.add($calConst.DATE,60)
#set( ${OpportunityList.get(0).Renewal_Date__c} = "MMM dd, yyyy" )
${date.format(
${OpportunityList.get(0).Renewal_Date__c},
$calNow,
$defaultLocale,
$defaultTimeZone
)}
This code is adding 60 days to today's date. It doesn't output anything from the Opportunity now.
(It's kind of lucky that it works at all now, actually, since you're overwriting the opportunity date with a date format.)
Can you explain exactly what you're trying to do with today's date and the Opportunity date(s)?
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 on weekly basis. How can I change it from "2020-11-09" to today's date?
I tried tips from your blog but my coding skills are not great so couldn't do it https://blog.teknkl.com/velocity-days-and-weeks/
#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>
Please open a new thread in Products and I'll answer there, thanks.