Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
We need to set up a one-time trigger flow on Shopify Flow. We're looking for someone to create this flow for us so that the action is automated in the store. I'm attempting to establish a workflow where whenever a new product or a product variant is added, it should verify if a color is included as a variant. If a color variant like 'Haute Red' is added, I want the metafield value 'red' to be assigned to that variant. Similarly, if a variant is added with the color 'sunshine', we want the metafield value 'yellow' to be assigned to it. All we're trying to do is assigna. main parent color value to all unique color children variant names. we started to create a flow but not sure how to feed the data to flow like to let flow know what metafield color value to assign to each variant...how can we do it?
Solved! Go to the solution
This is an accepted solution.
Hi Alalani, looks like this is possible using the Run Code action to map the parent color to the variant color names. I found that the color of a variant is under `selected options` in the api.
This would be the structure:
1. condition configuration:
2. Run Code configuration:
The script could be extended to handle more color options.
3. update product variant metafield configuration:
This would need changing to the correct namespace, key and type of metafield desired.
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
Looks like the metafield definition has "list of values" selected, which makes this a list of "single_line_text_field" instead of just "single_line_text_field". That's fine, we can fix the workflow by changing the metafield action a little.
1. select "list of single line strings" as the type
2. `["{{runCode.color}}"]` is the value
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
Hi Alalani, looks like this is possible using the Run Code action to map the parent color to the variant color names. I found that the color of a variant is under `selected options` in the api.
This would be the structure:
1. condition configuration:
2. Run Code configuration:
The script could be extended to handle more color options.
3. update product variant metafield configuration:
This would need changing to the correct namespace, key and type of metafield desired.
To learn more visit the Shopify Help Center or the Community Blog.
Hi @Alalani,
Have you tried implementing the suggestion @Jenny_W shared?
Thank you for your detailed explaination. Your solution has almost worked, but im encountering metafield value error. I followed your exact steps and the flow also got a trigger when I added a new variant color, but it couldnt assign the value and gave this error
'Got error updating metafield: "Type 'single_line_text_field' must be consistent with the definition's type: 'list.single_line_text_field'." For value: "blue", Type: single_line_text_field'
Attached some screeshots, all metafield value are set to the same 'single line text field'. Not sure what this error means... can you pls take a look?
This is an accepted solution.
Looks like the metafield definition has "list of values" selected, which makes this a list of "single_line_text_field" instead of just "single_line_text_field". That's fine, we can fix the workflow by changing the metafield action a little.
1. select "list of single line strings" as the type
2. `["{{runCode.color}}"]` is the value
To learn more visit the Shopify Help Center or the Community Blog.
Hi,
The code works perfectly fine the way you set it up and provided, it identifies the color variant values that you mentioned in the code and assigns a parent color value to it. However, when I try to add a new color variant name like for eg: I added the color 'Maroon' to the red list as you can see in the picture. It does not identify this new color in shopify and assigns it color as ' default value'. Why does the code only recognize the values you added? Do i have to add this new color 'Maroon' somewhere else also in the FLOW so it can identify in product listing and assign it color Red. Please advice....
Did you apply the changes to the workflow before testing?
To learn more visit the Shopify Help Center or the Community Blog.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025