Configure If / Else Statements

An If / else expression is a logical notation that evaluates a test statement. It executes a primary expression if the test is true and a secondary expression if the test is not true. You can also introduce additional test statements using the Add Else If option.

To add an if / else decision to the canvas and define its properties, see Add Decisions.

Follow these steps to configure the decision's logic:

  1. Double-click the if-else node to access its logic editor.
    Alternatively, select the node, and click Edit or View Decision Logic icon on the sidebar.
  2. In the if expression field, enter a test expression. 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 then and else fields. These fields have the expression notation selected by default.
    1. To change the logical notation for a field, click Options icon in its row, select Change Value, then select a different notation from the available options.
    2. Configure the logic for the selected notation.
  4. Optionally, add additional test statements.
    1. Click Add Else If.
      New fields labeled else if and then are added above the else field.
    2. Configure the logic for the new fields. You can change the logical notation for the newly-added then field.
    3. To delete the else if field, click Options icon in its row, and click Delete.
  5. To copy and paste data to or from a field, click Options icon in a field and select the required action.
  6. 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.

Here are a few examples of If / else decisions:

  • In the following example, the input value of temperature determines the output of the If / else decision:

    The image shows a decision called Weather created using the If-Then-Else notation. The values entered in the if, then and else fields are: Temperature > 25, “warm”, and “cool”, respectively. There's an Add Else If button at the bottom of the image.

  • The following example uses an additional test statement, precipitation > 50, through the else if field to determine the final output:

    The image shows a decision called Weather created using the If-Then-Else notation. The values entered in the if, then, else if, then, and else fields are: Temperature > 25, “warm”, Precipitation > 50, "rain", and "cool, dry", respectively.