How to Express a Logical Expression in the First and/or Second Value Field of a Step?

This topic was automatically generated from Slack. You can find the original thread here.

how does one express a logical expression in the first and/or second value field of a step?

For example I can have four items in a semicolon separated list and two values for which the step should terminate. How do I do that?

and two values for which the step should terminate
Hi , can you elaborate on this?

Hi again, so I have 4 values of an array {{steps.trigger.event.items[0].sku}}; {{steps.trigger.event.items[1].sku}}; {{steps.trigger.event.items[2].sku}}; {{steps.trigger.event.items[3].sku}} in which if I find the sku string constant CIO (and it almost always is in [0] unless a user cocks up something) or if I find the sku string constant PSR (usually in [0] also etc.) then I would not proceed to the next step. In a future implementation if I find PSR I might add data relating to that product on a dedicated spreadsheet. So how do I achieve that in one step or must I use two steps in any case?

Got it, thanks for explaining. Let’s ask Pi how to write the code

, I have an array of objects, steps.trigger.event.items. Every object in the array has a string field named sku. I want to exit the workflow if any of these object’s sku is equal to the string constant “CIO” or “PSR”. Can you help me write the Node.js code for this?

Certainly! Below is the Node.js code to exit the workflow if any object’s sku in the steps.trigger.event.items array is equal to the string constant “CIO” or “PSR”: export default defineComponent({ async run({ steps, $ }) { const items = steps.trigger.event.items; const skusToCheck = ["CIO", "PSR"]; for (const item of items) { if (skusToCheck.includes(item.sku)) { return $.flow.exit(`Exiting workflow because SKU is ${item.sku}`); } } console.log("No matching SKU found, continuing workflow..."); }, }); This code iterates over each object in the items array and checks if the sku field matches either “CIO” or “PSR”. If a match is found, the workflow exits with a message indicating the matching SKU. If no match is found, the workflow continues.

Oh, I think I misunderstood a bit regarding exiting the workflow. You want to exit the step only?