Use flow to list in-between numbers in a year range

Topic summary

A Shopify Plus user managing an auto parts store needs to automatically expand year ranges (e.g., 2012-2015) into individual years within Flow workflows. Currently, products link to vehicles via metaobjects with year ranges, but the storefront’s Make/Model/Year filter requires listing each year separately.

Two specific requirements:

  • Parse year ranges and generate all intermediate years (2012-2015 → 2012, 2013, 2014, 2015)
  • Handle “current” as a dynamic value that auto-updates to the present year annually

Proposed solutions:

  • Use Flow’s “Run code” action to parse and transform the year range strings programmatically (AI tools like Claude or ChatGPT can help generate the script)
  • Implement a Liquid template snippet using loops to iterate through year ranges, with {{ "now" | date:"%Y" }} capturing the current year dynamically

The discussion remains open with no confirmed implementation yet. The solution requires either custom scripting knowledge or leveraging AI assistance to write the transformation logic.

Summarized with AI on October 27. AI used: claude-sonnet-4-5-20250929.

Hi Guys,

I run an auto parts store.

Products are linked to a vehicle via a metaobject and then made “accessible” to site search and filters when flow passes that data into separate metafields

The issue I’m having is on our Make, Model, Year form. Specifically on the “year” portion since products fall in a year range not a singular year and I don’t want to list each year manually

Is it possible for flow to look at the year range e.g. 2012-2015 and list out the start, end and in-between years in the metafield? Here’s the example of the output I’d like:

Also, is it possible for flow to treat “current” (we use for models which don’t have a defined end year) as the current year and automatically update the year range when the year ticks over? Here’s the example of the output I’d like:

By solving this, we would able to list all the applicable years Make Model Year form on the front end in a concise/standardized way

Hi would love any advice. I can’t PM you (your PM settings must not be on). Please msg me directly when you’ve got that setup

Alternatively if you could steer me in the right direction in this public forum (even if only general principles) perhaps that advice could benefit someone else in future also…

To parse values from a single string and form a new string, it’s convenient to use the Run code action. If you don’t have programming skills, an AI like Anthropic Claude or ChatGPT should be able to handle such a script effectively.

Not sure what type of metafield you have, but something like this in liquid might work when setting that metafield:

{% capture this_year %}{{ "now" | date:"%Y" }}{% endcapture %}
{% capture first_year %}{{product.myMetafield.value | first}}{% endcapture %}
{% for year in (first_year..this_year) %}
{{ year }}
{% endfor %}