Skip to main content
Question

Workflow javascript to evaluate customer order lines

  • August 27, 2026
  • 1 reply
  • 28 views

Forum|alt.badge.img+4

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

};

1 reply

Marcel.Ausan
Ultimate Hero (Partner)
Forum|alt.badge.img+22
  • Ultimate Hero (Partner)
  • August 28, 2026

@derbar I quickly created a workflow that would show an error message when users try to release a CO that has lines with price 0.

Unfortunately it seems bpmn files cannot be attached here. Anyways, I share a few printscreens and the javascript block.

 

Javascript block:

var raw = execution.getVariable('CustomerOrderLineSet_Set');

var hasZeroPrice = false;
for (var i = 0; i < raw.size(); i++) {
if (Number(raw.get(i).get('BaseSaleUnitPrice')) === 0) {
hasZeroPrice = true;
break;
}
}

execution.setVariable('hasZeroPrice', hasZeroPrice);