If then else

Event action – Abstract

Purpose: Evaluates one or possibly more rules to allow case discrimination between alternative blocks of event actions within an event handler.

The event action If then else can be used to specify a case distinction or the conditional execution of actions in an event handling depending on Regeln.

As outlined in the following scheme, starting from a simple condition (IFTHENACTIONS), the case distinction can be extended modularly via further rules in the ELSE part, with each new (ELSE) IF rule opening a new branch with its own actions.

Specifying a rule is technically optional in any branch. However, for a branch without a rule, the default is 'Static: True' (see Static rule), which makes further ELSE branches irrelevant. In this respect, a rule should only be omitted in the 'final' ELSE branch.

Of course, if necessary, the If then else can also be 'nested', that is, used within the actions of a branch of another If then else event action.

images/download/attachments/201663456/image2021-4-27_11-55-25-version-1-modificationdate-1742405362504-api-v2.png

Configuration

When collapsed, an If then else event action appears by default as shown in the upper right corner. The value in the label (here: 3) indicates by default the number of configured branches of case distinction.

Below, a just inserted If then else event action can be seen expanded, which also does not contain a branch at the beginning. The first branch can be created by clicking on the images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/add.svg icon.

images/download/attachments/201663456/image2021-4-27_11-58-9-version-1-modificationdate-1742405362501-api-v2.png

When a first branch is added to the case distinction, the following controls are available:

  • The placeholder for an IF rule (1), where available Rule types can be selected by clicking on images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/add.svg .

  • The placeholder for THEN actions (2), where event actions can be added by clicking on images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/add.svg .

  • The placeholder for the OTHER branch (3), where another branch (with rule and action block) can be added by clicking the images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/add.svg icon.

  • The menu icon (4), via functions for 'Copy', 'Cut' and 'Paste' of the complete branch are available (if applicable). For example, an existing branch can be copied and pasted via the context menu of the OTHER branch placeholder (3).

images/download/attachments/201663456/image2021-4-27_12-0-12-version-1-modificationdate-1742405362499-api-v2.png

NOTE◄ In practice, it may be necessary to subsequently change the order of branches in an If then else event action. This is possible with the context menu functions for 'Cut' and 'Paste'.

However, changes to the sequence can also be executed via drag & drop in the tree view of the event handler:


The screenshot on the right shows an If then else event action with two branches (IF Company rule ELSE-IF Role rule).

The screenshot below shows a section of the tree view for this configuration:

images/download/attachments/201663456/image-2025-3-20_14-5-26-version-1-modificationdate-1742475926272-api-v2.png

  • The node for the Company rule is selected in the tree view.

images/download/attachments/201663456/image-2025-3-20_14-3-34-version-1-modificationdate-1742475814249-api-v2.png

  • If the node for the branch with the Company rule is dragged and dropped below the node with the Role rule in the tree view, the corresponding branches swap places in the flow diagram (right). By drag & drop, the THEN branch becomes an (ELSE) IF branch and vice versa.

images/download/attachments/201663456/image-2025-3-20_14-6-47-version-1-modificationdate-1742476006897-api-v2.png


NOTE◄ The order of the branches can have a significant impact on the logic of case differentiation and even the performance of event handling. If the logic allows, potentially computing-intensive checks (e.g. a Check existence) should be arranged as far to the right as possible in the chain. They may be executed 'less frequently' as a result.

images/download/attachments/201663456/image-2025-3-20_14-2-55-version-1-modificationdate-1742475775006-api-v2.png

Examples

Simple use case: Conditional execution of an action

Within an event handling, a specific view (e.g. a modal dialog) is opened exactly when the login context refers to a certain role ('Administrator').

images/download/attachments/201663456/image-2025-3-20_14-8-31-version-1-modificationdate-1742476110712-api-v2.png

  • A Role rule is used here as an IF rule, which checks whether the selected role “Administrator” is used in the applicable login context (see Role of session).

  • In the corresponding THEN branch, the action Open view (Action) is attached below it.

More complex use case: Multi-branch case distinction

The previous example is expanded so that a specific view appears for the roles 'Basic user' and 'Anonymous user' and only a simple popup note appears for other roles.

images/download/attachments/201663456/image-2025-3-20_14-11-50-version-1-modificationdate-1742476309439-api-v2.png

  • The already existing branch (rule and action) can be copied via the menu icon and inserted as a new ELSE branch.

  • Then, the settings for the Role rule and the THEN action for the copied branch can be adjusted as shown in the image.

  • Another ELSE branch is added which does not contain an IF rule, only the THEN action Show alert (Popup).

NOTE◄ In the example, the logged-in user can only use one specific role at a time, so the order of the branches with the rules does not matter. If, on the other hand, different independent criteria are checked, the order of branches plays an important role, because the case distinction is only processed from left to right as long as none of the rules are passed.