We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

How do I add to a metaobject list while retaining the previous list items?

How do I add to a metaobject list while retaining the previous list items?

impertiknits
Shopify Partner
3 0 0

So far, if I update the metafield (which is a list metaobject) with the following as the value, and the existing value of the metafield is blank, it will work tickety-boo, no trouble:

 

["gid://shopify/Metaobject/26233635050","gid://shopify/Metaobject/26233733354"]

 

However, if the metaobject list already has a value, it will overwrite it and lose the original values.  Is there a way to retain that information and simply add to it?

 

Thanks for any help in advance!

Reply 1 (1)

paul_n
Shopify Staff
1828 199 435

Yes, you need to merge those new metafield values with the existing values. You can do that using "Run code" or using Liquid in the action. There are a few threads that show how to handle merging lists, like this one: https://community.shopify.com/c/shopify-flow-app/how-can-i-convert-product-tags-into-metafield-singl...

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.