How to make sure product metafield is not one of the ones from a list of options

I want to add a step where Flow will check if a product metafield is not one of the values from a list of values. For example if my product metafield is colors, I want to make sure the product metafield is not one of these (ie blue, green, purple, red, orange…). The list will probably be very large and variable so I need a way to store it somewhere and be able to change it as well. Is this able to be done in run code? And if so, can I get an example of how (have never used run code before) ? Thanks!!

KIndly drop your webiste URL

Hi There,

You can certainly use “Run code” to achieve this. The JavaScript would be:

const denylist = [
  'blue',
  'green',
  'purple',
  'red',
  'orange'
];

export default function main() {
  return { denylist: denylist };
}

With the “Define outputs” section as:

"The output of Run Code"
type Output {
  "Colour denylist"
  denylist: [String!]!
}

This could then be used in a condition compared against a metafield (here I’m using a product variant metafield custom.colour):

1 Like