SOLVED

Re: Token for year?

Go to solution
Geoff_Krajeski1
Level 10 - Champion Alumni

Is there any way to get the system YEAR in a token?

This is in reference to the copyright date in each of our fulfillment emails.

Rather than having to update hundreds of of FEs each year in January, I would proper and ask if it is possible to get a token for something like {{system.dateYear}}.

1 ACCEPTED SOLUTION
Geoff_Krajeski1
Level 10 - Champion Alumni

This works like a charm!

$date.get('yyyy')

View solution in original post

19 REPLIES 19
Tim_Askerov
Level 1

This seems to have stopped working for me. Anyone else experience this?

Casey_Grimes
Level 10

The New Year is Coming. Don't be "That Company" – Update Your Date!

#set($timeZoneObject = $date.getCalendar().getTimeZone())

$date.format("yyyy", $date.getDate(), $date.getLocale(), $timeZoneObject.getTimeZone("EST"))

Anonymous
Not applicable

I just started using this script to get the date but suddenly realized it does not work when you click the "view this email as a webpage" link. I literally see the code.

Can someone else please verify this? Thank you

SanfordWhiteman
Level 10 - Community Moderator

Open a Support case. Some instances don't execute Velocity in Web Page View due to a configuration error. Once fixed on the back end it'll be fine.

Anonymous
Not applicable

I know I'm a bit late to the conversation, but $date.get('yyyy') works if added to the global footer HTML and Text fields under 'Admin > Email.'  That's one option of not having to update tons of assets and programs.

Grégoire_Miche2
Level 10

Hi Geoffrey,

A velocity script should be able to do this easily. See http://developers.marketo.com/documentation/velocity-script/

-Greg

Geoff_Krajeski1
Level 10 - Champion Alumni

Thanks Grégoire Michel, I will have to take a look at that!

Geoff_Krajeski1
Level 10 - Champion Alumni

This works like a charm!

$date.get('yyyy')

Kim_Gandy1
Level 7

Hi Geoff Krajeski​, how do I input this code into the required token field? When I just copy/paste, it errors. Thanks!

Geoff_Krajeski1
Level 10 - Champion Alumni

It is not a token field.  This is velocity scripting Kim Gandy​.  You just add it to your email or template.

It's been working just fine for me and the team at PR Newswire.

If you need further Velocity knowledge you can look here: http://developers.marketo.com/email-scripting/

I have not yet experienced the potential issues Sandy describes above, but will be interested to see come the flip of the year.

Kim_Gandy1
Level 7

Is there any way to create this on a system level? Adding script to each program would be very time consuming.

Anonymous
Not applicable

We have set up a bunch of inherited tokens for such things. Dates, Year, months, regionalised addresses. They'll trickle down and be available in all programs.

Geoff_Krajeski1
Level 10 - Champion Alumni

Yes, with the addition of global tokens (inherited) that would be the way to go!

Geoff_Krajeski1
Level 10 - Champion Alumni

Kim Gandy ,

It unfortunately is a time consuming process (but great for holiday week work LOL).

My recommendation is to create a snippet (honestly) so that the redundancy is one-fold, and you only need to change in one place!

I am still dealing with this in a super large instance with 450+ programs to handle.

Kim_Gandy1
Level 7

Haha, true about holiday work week.

I was able to add this successfully for two programs, but two others became a complete cluster upon adding. Have you ever had trouble with approving email assets after adding this script to email templates? Support "worked" on this all morning, but still never came up with an answer.

Geoff_Krajeski1
Level 10 - Champion Alumni

Kim Gandy

I have yet to experience an issue. 

However, I think there was one noted on the "View as webpage".

Can't recall the resolution specifically though...

Kim_Gandy1
Level 7

To clarify, you experienced an issue on emails using "view as webpage"?

Geoff Krajeski​, can I run a scenario by you? Depending on the campaign, my team is cloning programs/emails or creating new. I know they won't remember to add script to each new program, and I don't want 2016 in any emails for the new year. In order to catch every email, does it make sense to:

  1. Add script to all existing programs and input into existing emails.
  2. Change year to 2017 in email templates in Design Studio. This would catch new program/email when user forgets to add script to new program.

I'm sure I'm overthinking this, but let me know what you think.

SanfordWhiteman
Level 10 - Community Moderator

Kim, Velocity output in Web Page view has been irregular across instances. I wrote a well-warranted blog post about it -- only to have it be "fixed" in my primary instance within the next month. However, I haven't seen it regress in any instances once it got fixed, and according to Mkto engineering, it is expected to work (I assume there was a module loading order/omission problem on the instances that had the prob.

SanfordWhiteman
Level 10 - Community Moderator

Careful with timezones.  I know it sounds crazy, but unless you know the input and output timezones are the same (not necessarily the case on your Marketo pod/instance) even when only using the YYYY part, you'll be out of alignment for a few of hours around the turn of the year.

Ordinarily, that small period over the whole year isn't a big deal (compared to the regular problems you'll encounter if using full days and times) but since you're specifically using this to roll over into the New Year, if someone double-checks while they're watching the Big Ball drop, they may think it's broken.