SOLVED

Fetch Month/Year via Email Scripting

Go to solution
Highlighted
Anonymous
Not applicable

Fetch Month/Year via Email Scripting

Hello Everyone,

I have an email which is to be sent periodically, I was wondering if there is a way to automatically fetch the current month/last month/current year. Much like a token would do. I tried to google it but I could only find it could be done using Email Scripting Token.

My email line reads like this:

"Please submit any pending reports for upload for the month of <Last Month>. The last date for submission is 10th, <Current Month> <Current Year>."

Is there any way it can fetch the information automatically.

Thank you in advance.

Harshit

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Fetch Month/Year via Email Scripting

Hi Harshit,

#set($calendar = $date.getCalendar())  

$calendar.add(2,-1) 

$date.format('MMMM',$calendar)

(come back and mark me as correct if this works for you).

#set($calendar = $date.getCalendar())   //get a calendar

$calendar.add(2,-1)  //use the calendar add tool, init month (2) and -1

$date.format('MMMM',$calendar)  //display the date in the format MMMM

View solution in original post

14 REPLIES 14
Highlighted

Re: Fetch Month/Year via Email Scripting

Hello Harshit,

The easiest way to do this is through the Velocity email scripting. There is no Marketo UI for this functionality.

Best,

Pavel

Highlighted
Anonymous
Not applicable

Re: Fetch Month/Year via Email Scripting

Hello Pavel,

The velocity email scripting link is not accessible from the Marketo doc, is there any other document or link which could guide?

Thanks,

Harshit

Highlighted
Anonymous
Not applicable

Re: Fetch Month/Year via Email Scripting

Hello Pavel,

I was able to fetch the current month and year using the velocity script: $date.get('MMMM, yyyy')

However I am not able to fetch the "last month". Could you help me with the script to do so?

Thanks,

Harshit

Highlighted
Level 5

Re: Fetch Month/Year via Email Scripting

Hi Harshit Pandey​,

You can find it on the developer website. Find the link below:

http://developers.marketo.com/documentation/velocity-script/

Hope this helps.

Highlighted
Anonymous
Not applicable

Re: Fetch Month/Year via Email Scripting

Hey Ravi,

Thank you for your prompt response, however I do not have any exposure to scripting and such so I was wondering if anyone could help me with the script itself so I could place it in custom token. Any help will be much appreciated.

Thank you for your time.

Highlighted
Anonymous
Not applicable

Re: Fetch Month/Year via Email Scripting

Hello Ravi,

I was able to fetch the current month and year using the velocity script: $date.get('MMMM, yyyy')

However I am not able to fetch the "last month". Could you help me with the script to do so?

Thanks,

Harshit

Highlighted

Re: Fetch Month/Year via Email Scripting

Hi Harshit,

#set($calendar = $date.getCalendar())  

$calendar.add(2,-1) 

$date.format('MMMM',$calendar)

(come back and mark me as correct if this works for you).

#set($calendar = $date.getCalendar())   //get a calendar

$calendar.add(2,-1)  //use the calendar add tool, init month (2) and -1

$date.format('MMMM',$calendar)  //display the date in the format MMMM

View solution in original post

Anonymous
Not applicable

Re: Fetch Month/Year via Email Scripting

Hey Nicholas,

You are the savior, it worked like a charm.

Thank you so much

Harshit

Highlighted
Level 1

Re: Fetch Month/Year via Email Scripting

Marketo now supports the token {{system.dateYear}} to populate current year. It is case sensitive. Other similar tokens like {{system.dateMonth}} and {{system.dateDay}} are not supported.

Marketo Certified Expert