SOLVED

Velocity Script in Email Token

Go to solution
Highlighted
Anonymous
Not applicable

Velocity Script in Email Token

Hi Community


I am trying to add hours to marketo date and time field which is sync with SFDC custom object and fetch data from SFDC custom object.

Problem here is velocity script is not working in this field, is it because its stored as string not as object?
I have refereed following doc, Adding Days and Comparing Dates

my script goes like this:

#set($x = ${lead.Date}.calendar)

$x.add(10,7)

$x.time

I need to add 7 hour to date that i get in lead.Date field (Originally problems comes because custom object which is sync, does not calculate time zone and i am having 7 hour different in data that I have in marketo, than in SFDC custom object )

any help will be appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Velocity Script in Email Token

try this:

#set ( $x = $convert.parseDate(${lead.Acquisition_Date},"yyyy-MM-dd hh:mm:ss") )

#set( $calendarObj = $convert.toCalendar($x) )

$calendarObj.add(10,7)

$date.format("yyyy-MM-dd hh:mm:ss",$calendarObj)

View solution in original post

8 REPLIES 8
Highlighted

Re: Velocity Script in Email Token

try ${lead.Date}.getCalendar()

Highlighted
Anonymous
Not applicable

Re: Velocity Script in Email Token

I am getting error in script while trying send sample email, emailScript.PNG

Highlighted
Marketo Employee

Re: Velocity Script in Email Token

Can you paste a copy of your current script?

Highlighted
Anonymous
Not applicable

Re: Velocity Script in Email Token

#set($x = ${lead.Date}.getCalendar())

$x.add(10,7)

$x.time

Highlighted
Marketo Employee

Re: Velocity Script in Email Token

Doesn't look like the issue is in the script itself.  Could you share the whole HTML of the Email?  There is probably an issue parsing somewhere further along

Highlighted
Anonymous
Not applicable

Re: Velocity Script in Email Token

I am using blank template to check email script token, There is noting else in email. And Error message is difficult to understand in script level.

email contains

Date = {{lead.Subcription Date:default=edit me}}

Formated Date  = {{my.FormattedDate:default=edit me}}

Highlighted

Re: Velocity Script in Email Token

try this:

#set ( $x = $convert.parseDate(${lead.Acquisition_Date},"yyyy-MM-dd hh:mm:ss") )

#set( $calendarObj = $convert.toCalendar($x) )

$calendarObj.add(10,7)

$date.format("yyyy-MM-dd hh:mm:ss",$calendarObj)

View solution in original post

Highlighted
Anonymous
Not applicable

Re: Velocity Script in Email Token

Thanks Justin, it helped

-Indu