I am looking to see if there are examples of javascript loops that can be used in a workflow to evaluate if any line on a customer order has a $0 BaseSaleUnitPrice. If so, the customer order would be prevented from being released. I have used the following script, but this and others throw errors. This seems to be the most efficient I have seen. I am using the IFS API path in the workflow. Any advice or examples would be greatly appreciated.
let hasZeroPrice = false;
for (const line of CustomerOrderLineSet.OrderLinesArray) {
if (line.BaseSaleUnitPrice === 0) {
hasZeroPrice = true;
break; // Stop early once found
}
}
return {
hasZeroPrice: hasZeroPrice
};