SAP Open Connectors

Formulas - How to Aggregate Loop Step Results

To aggregate the results from a loop in a formula, use the last step of the loop as an aggregator. For example, you can make a Javascript step called aggregator  and use use the following code snippet:

let arr = steps.aggregator ? steps.aggregator.arr : [];

<insert custom logic>

done({arr:arr})

This Javascript checks to see if the current step has already run and, if it has, it will get the results from the last time the step ran and add to them or if it has not run it will start with an empty array.