Create loops to iterate over lists or arrays. Using the loop logical notation, you can create three different types of loops, namely For, Some, and Every.
- For: Iterates over a list and returns an expression.
- Some: Checks if at least one list item satisfies the test condition defined by an expression and returns a Boolean value.
- Every: Checks if every list item satisfies the test condition defined by an expression and returns a Boolean value.
To create a decision with the Loop logic:
- Click Add new decision in the Decisions bar and select Loop from the Create Decision window. An empty loop decision appears.
- In the Operation column, choose the type of loop to create from the drop-down menu. In the corresponding expression field, enter the loop variable.
- In the in field, enter the list or array over which to iterate. In the return or satisfies fields, enter the expression to return (For loop) or the test expression (Some and Every loops), respectively. Press Ctrl+Space to view an auto-suggest menu. You can use any decision outputs, variables, functions, and keywords listed in the menu to define expressions in the in, return, and satisfies fields. Use the FEEL syntax to define expressions.
- If necessary, change the logical notations for return and satisfies fields to create a nested logic. These fields have the expression notation selected by default. Click Change body and select a different notation from the available options. Configure logic for the selected notation. From the Change body menu, you can also cut or copy a notation from these fields and paste it into another identical field within the model.
- Furthermore, for a For loop, you can add an additional condition, where, using the Add Condition button.
- After the decision logic is complete, click Save to save and validate changes manually. Changes you make within the decision model are also automatically saved and validated from time to time. Errors, if any, are displayed within the decision.
- The following example shows a simple For loop that returns the squares of list items:
- The following decision contains a Some loop that checks if at least one element in the list is greater than 50:
- The following decision contains an Every loop that checks if every element in the list is greater than 50: