1 Reply Latest reply on Mar 24, 2016 9:16 AM by Grégoire Michel

    Velocity scripts, email preview and user locale

    Grégoire Michel

      For anyone interested in creating velocity scripts and working in an international environment. Here is the code we have been using :

      #set($myDate = $convert.parseDate(${lead.datefield}, 'MMM dd, yyyy'))

      $date.format('dd/MM/yyyy', ${myDate})

      The script works well when the email is sent through a smart campaign, no problem. But if you try to preview the email (email actions -> preview), whether or not it will work depends on your use settings, and more precisely on the locale. If you use english, no problem, but if you are set in French or Spanish, it does not work. Very disturbing!

       

      The reason is because the "lead.datefield" field is not rendered in english format when previewing, but in a format that is dependent on the user's locale.

       

      Recommendation, if you want to develop velocity scripts, set your locale to english! Too bad for the others

       

      We have wasted a couple of hours to understand why the script above would not work, and developers also have changed the 'MMM dd, yyyy' to other formats, which made the preview work, but broke it when sending through the smart campaign.

       

      -Greg