最近搜索


没有最近搜索

Dynamic Years Using Liquid Markup

已回答


已于 2023年11月10日 发布

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 条评论

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


请先登录再写评论。

找不到所需的内容?

新建帖子