Create Loops

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 a new array/list containing calculated results in each index as per the expression defined in the result field.
  • 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:

  1. Add a new decision element to the model.
    1. On the Diagram palette, under Decisions select Relation, and drag it onto the canvas.
    2. Double-click the element to edit its logic. You can also edit the element's logic from the Decision Properties pane; click the three dots on the element, then select Edit to open the Decision Properties pane. In the Decision Properties pane, click Edit Edit icon next to the Name field.

    An empty loop decision is created.

  2. 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.
  3. 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 a suggestion list. You can use any decision outputs, variables, functions, and keywords in the list to define expressions in the in, return, and satisfies fields. Use the FEEL syntax to define expressions.
  4. 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 Value Change Value icon and select a different notation from the available options. Configure logic for the selected notation.
  5. Furthermore, for a For loop, you can add an additional condition, where, using the Add Condition button.
  6. Changes you make within the decision model are automatically saved and validated from time to time. Errors and warnings, if any, are displayed within the decision panel.

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: