Recent searches


No recent searches

Dynamic Years Using Liquid Markup

Answered


Posted Nov 10, 2023

I have a team with a macro that always references next year, and they have to manually go in there once a year and increment by 1. Is there a way to capture the current year, add one, and that macro is evergreen now?


0

1

1 comment

image avatar

Jacob the Moderator

Zendesk LuminaryCommunity Moderator

Hi Chris Gregory 👋

You sure can! I'm not a Liquid Markup expert, but have managed to get something working for your use case.

Below, I'm using the {{ticket.updated_at_with_timestamp}} placeholder that captures the timestamp of the ticket update (using the macro) and isolates the first part - the year. If you want to capture the year of a different event, like ticket creation, then you can use {{ticket.created_at_with_timestamp}} to capture that - there are other options as well

The current year is:
{{ticket.updated_at_with_timestamp | split:'-' | first }}

Next year is:
{% assign year = ticket.updated_at_with_timestamp | split:'-' | first | plus: 0 %}{% assign next_year = year | plus: 1 %}{{ next_year }}


I hope this helps you out, let me know if you have questions.

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post