2 Replies Latest reply on Jan 11, 2017 2:49 PM by Phillip Wild

    Email scripts: using dates

    Phillip Wild

      Hi everyone

       

      Having a bit of trouble formatting dates through email scripting.

       

      Here's my initial code:

       

      <ul>

      #foreach ($Tour_Details in ${TravellerServices__cList})

          #if (${Tour_Details.Service_Status__c} == "Confirmed" && ${Tour_Details.ServiceTypeTS__c} == "Tour")

        <li>You took ${Tour_Details.Service_Dossier_Name__c} on ${Tour_Details.Service_Start_Date__c}).

        </li>

          #end

      #end

      </ul>

       

      This gives me this:

       

      • You took ATTW on 2013-03-16.
      • You took PAA on 2014-06-30.

       

      Good so far!

       

      Next I tried to format the dates to say "16 March 2013" instead of the current format. So I tried:

       

      #foreach ($Tour_Details in ${TravellerServices__cList})

          #if (${Tour_Details.Service_Status__c} == "Confirmed" && ${Tour_Details.ServiceTypeTS__c} == "Tour")

        <li>You took ${Tour_Details.Service_Dossier_Name__c} on $date.format('dd mmm yyyy' ,${Tour_Details.Service_Start_Date__c}).

        </li>

          #end

      #end

      </ul>

       

      But this gives me:

       

      • You took ATTW on $date.format('dd mmm yyyy' ,${Tour_Details.Service_Start_Date__c}).
      • You took PAA on $date.format('dd mmm yyyy' ,${Tour_Details.Service_Start_Date__c}).

       

      Something is obviously wrong. Any ideas?

       

      As a side note, while playing around I tried to use Marketo's example, found here: http://developers.marketo.com/email-scripting/

      http://developers.marketo.com/email-scripting/

       

      #set($birthday2015 = "2015-08-07")

      ##use whenIs to determine how many days away it is

      $date.whenIs($birthday).days ##outputs 1

       

      This doesn't seem to work. The output is:

       

      $date.whenIs($birthday).days

       

      It didn't work even when I renamed the variable from $birthday to $birthday2015 in the last line, which I thought might be the error.

       

      Is there something I need to do to "load" the $date functionality in scripting?

       

      Thanks, Phil

       

      $date.whenIs($birthday).days ##outputs 1