Condition to make the flow check for certain values in a Metafield

Hi,

I want to create a flow where products that are on Draft and have more than 0 stock are put back on Active. But as extra condition, I want to make it check if certain values are not filled in a metafield. I can’t make the flow values match the orginal ones. They are never recognised, so I need some help to formulate the right value in the flow so it matches. The values in the metafields are list items, 3 of those values if filled in should stop the flow, these list items are:

  • Draft - Out of Stock (Shopify stock incorrect)
  • Draft - Quarantine
  • Draft - Unsendable Products (food, glass, …)

I provided a screenshot below (can’t seem to add export of the flow?). I tried many other things, this is just the latest example of one that doesn’t work. Tried both with string and JSON values. I’m not a coder at all, so I think I’m just missing the right way to input the values?

Thanks in advance!!!

1 Like

Hi @Kilian_A ,

Since your metafield is a list of values, each value is stored as a separate string item, not as one large JSON string.

Rather than comparing against a full JSON string (like [“Draft - Out of Stock (Shopify stock incorrect)”]), you need to check whether any list item matches one of the blocked values, like this:

In your third condition block, change it to:

IF: Any of product / metafields
Metafield list item value → is equal to → Draft - Out of Stock (Shopify stock incorrect)

Click Add criteria

Metafield list item value → is equal to → Draft - Quarantine

Click Add criteria

Metafield list item value → is equal to → Draft - Unsendable Products (food, glass, …)

Change the condition mode to OR between them

Then under “If true”, use Fail workflow

Under “If false”, continue to set product to Active

Please try this once and do let me know if issue persists !

Thanks !

Hi,

Should I keep using the “json value” or switch to “string” again like the screenshot?

Kilian_A_1-1749047670644.png

Here I tried your recommendations with the “json value” still and that didn’t work.

This is the output of the condition for a product that had the “Draft - Quarantine” filled in the metafield:

[“Draft - Quarantine”] is added after the “,” each time at the end (cut of in the screenshot and can’t have it shown in flow for some reason)

Hi @Kilian_A ,

From the screenshots:

Your metafield values are stored like this: [“Draft - Quarantine”]

But Shopify Flow evaluates each item in a list individually when you use the correct field, not json value.

What to do instead:-
Use:

Field: product / metafields

Condition Type: Metafield list item

Comparison: is equal to

Value: Draft - Quarantine (exact plain string, no brackets or JSON)

Then repeat the condition with OR for:

Draft - Out of Stock (Shopify stock incorrect)

Draft - Unsendable Products (food, glass, …)

Final Condition Block Setup
IF → Any of product / metafields

Metafield list item is equal to Draft - Out of Stock (Shopify stock incorrect)

OR

Metafield list item is equal to Draft - Quarantine

OR

Metafield list item is equal to Draft - Unsendable Products (food, glass, …)

Don’t use json value, that is meant for comparing raw JSON arrays, and your flow won’t match individual list items properly using that.

After setting this up:

Add a product with only Draft - Quarantine in the metafield

Change stock to trigger the flow

It should now match and block the flow

Let me know your metafield’s namespace and key (e.g., custom.status_blocking) if you want me to show exactly where to apply this.

Thanks !

1 Like

Don’t loop over metafields like this. If any one of them has a large value, it can stop your automation from working, because you’ll hit an API limit.

Instead you add the metafields individually to the workflow and then you can check the value for a single metafield. To do that, you choose “product / metafield” not “Metafields” plural. Instructions https://help.shopify.com/en/manual/shopify-flow/concepts/metafields#get-metafield-data

This worked like a charm!

I have stumbled on it before, but I was a bit lost with the Alias before, now it made sense.

Thanks!!!

Hi Steven,

Got it fixed with the recommendations of another comment.

Appreciate you willing to help though!

Cheers