Configure 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 an array or a list containing the results.
  • 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 add a loop decision to the canvas and define its properties, see Add Decisions.

Follow these steps to configure the decision's logic:

  1. Double-click the loop node to access its logic editor.
    Alternatively, select the node, and click Edit or View Decision Logic icon on the sidebar.
  2. Configure a For loop.
    1. In the Operation column, choose For in the drop-down menu. In the corresponding expression field, enter the loop variable.
    2. In the expression field of the in row, enter the list or array over which to iterate. Click the field to view a suggestion list, containing decision outputs, variables, functions, and keywords. You can use these suggestions to define expressions or write your own using the FEEL syntax. See About Friendly Enough Expression Language.
    3. Configure the logic for the return field. The field has the expression notation selected by default.
      1. To change the logical notation for the field, click Options icon in its row, select Change Value, then select a different notation from the available options.
      2. Configure the logic that calculates and returns the result.
    4. Optionally, add an additional condition.
      1. Click Add Condition.

        A new field labeled where is added above the return field.

      2. Enter the expression for the where field.
      3. To delete the where field, click Options icon in its row, and click Delete.
  3. Configure a Some or Every loop.
    1. In the Operation column, choose Some or Every from the drop-down menu. In the corresponding expression field, enter the loop variable.
    2. In the expression field of the in row, enter the list or array over which to iterate. Click the field to view a suggestion list, containing decision outputs, variables, functions, and keywords. You can use these suggestions to define expressions or write your own using the FEEL syntax. See About Friendly Enough Expression Language.
    3. Configure the logic for the satisfies field. The field has the expression notation selected by default.
      1. To change the logical notation for the field, click Options icon in its row, select Change Value, then select a different notation from the available options.
      2. Enter a test expression or logic.
  4. To copy and paste data to or from a field, click Options icon in a field and select the required action.
  5. To reuse the entire logic definition in another decision, cut or copy it and paste it into the desired decision. Click Options icon in the header and select the required action.
Changes you make within the decision model are automatically saved and validated. Errors and warnings, if any, are displayed in the editor. Click the error or warning icon to review and fix them. See Review and Fix Errors in a Decision.
  • The following example shows a simple For loop that returns the squares of list items:

    The image shows a Loop decision called Square. The decision contains a table of two columns and three rows. The two columns are: Operation and Name or Expression. In the Operation column, For is selected in the first row, and the second and third row display in and return, respectively. The three rows of the Name or Expression column are populated as follows: n, [1,2,3,4], n*n.

  • The following decision contains a Some loop that checks if at least one element in the list is greater than 50:

    The image shows a Loop decision called Greater Than. The decision contains a table of two columns and three rows. The two columns are: Operation and Name or Expression. In the Operation column, Some is selected in the first row, and the second and third row display in and satisfies, respectively. The three rows of the Name or Expression column are populated as follows: n, [12,50,51], n>50.

  • The following decision contains an Every loop that checks if every element in the list is greater than 50:

    The image shows a Loop decision called Greater Than. The decision contains a table of two columns and three rows. The two columns are: Operation and Name or Expression. In the Operation column, Every is selected in the first row, and the second and third row display in and satisfies, respectively. The three rows of the Name or Expression column are populated as follows: n, [12,50,51], n>50.