--- title: "Break loop" slug: "core-break-loop-actor" updated: 2026-04-01T08:58:38Z published: 2026-04-01T08:58:38Z canonical: "docs.lobstersoftware.com/core-break-loop-actor" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # Break loop > [!NOTE] > Event action – Abstract > > **Purpose**: This event action immediately ends the execution of actions and the iteration in a parent [For each loop](/v1/docs/en/core-for-each-entity-actor) without aborting the entire event processing. > > > [!TIP] > > Tooltip > > > > - **Usage**: The event action is only useful within a [For each loop](/v1/docs/en/core-for-each-entity-actor). As a rule, [Break loop](/v1/docs/en/core-break-loop-actor) is used in the *action block* of the relevant loop. However, the aborted loop can also be located in a called event handling. The use of [Break loop](/v1/docs/en/core-break-loop-actor) only makes sense in the context of an event action with a case distinction (e.g. [If then else](/v1/docs/en/core-if-then-else-actor), [User callback](/v1/docs/en/core-user-callback-actor), [Try/Catch actor](/v1/docs/en/core-try-catch-actor)), unless the parent loop should be terminated for test purposes. > > - **NOTE:** The event action does not provide any information on the loop termination (no flag, no index value) for any subsequent event processing. Corresponding assignments must be configured explicitly if required. ![images/download/attachments/189440306/image-2024-11-28_11-50-38-version-1-modificationdate-1732889618078-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-11-28_11-50-38-version-1-modificationdate-1732889618078-api-v2.png) The [Break loop](/v1/docs/en/core-break-loop-actor) event action is used to stop the iteration of a parent [For each loop](/v1/docs/en/core-for-each-entity-actor) event action with immediate effect. Event processing is then continued after or 'below' the loop. - If multiple instances of the [For each loop](/v1/docs/en/core-for-each-entity-actor) event action are used in a nested manner, the [Break loop](/v1/docs/en/core-break-loop-actor) event action only ends the iteration at the level at which it is executed. Parent level loops are not cancelled. - In special cases, the [For each loop](/v1/docs/en/core-for-each-entity-actor) event action to be cancelled is located in a *calling* event handling that directly or indirectly triggers the event handling with the [Break loop](/v1/docs/en/core-break-loop-actor) event action in the context of the loop. Typically, the cancellation of the loop is linked to the evaluation of a *cancellation criterion*, the evaluation of which requires a case distinction in the *action block* of the loop: - Generally, the [If then else](/v1/docs/en/core-if-then-else-actor) event action is used to represent the conditional execution of [Event actions](/v1/docs/en/core-i-action-actor-configuration) (depending on a *rule configuration*; see [Rule types](/v1/docs/en/core-association-rule)). - The [User callback](/v1/docs/en/core-user-callback-actor) event action handles the special case where the decision is queried interactively by the user rather than being determined by rule. - The [Try/Catch actor](/v1/docs/en/core-try-catch-actor) event action can be used to end a loop in response to an error without halting event processing altogether. **NOTE:** Although the `$index` variable serves as a loop counter during the execution of a loop, it is only available within the *action block*. This means that it is not possible to determine in which iteration the cancellation was triggered by direct read access to the `$index` variable after a loop has been cancelled by the [Break loop](/v1/docs/en/core-break-loop-actor) event action. ## Configuration The [Break loop](/v1/docs/en/core-break-loop-actor) event action does not use any parameters. ## Examples ### Simple use case: Cancelling a checklist at the first unconfirmed input The release of a tour should only be triggered if the user confirms all steps of a small checklist, which is available as a list of text values (`String[]`) in a `checklist` variable. - As soon as an input is not confirmed by the user, the processing of the checklist should be cancelled. - After an abort, the `abortIndex` variable refers to the list item that has not been confirmed. - The following steps should be carried out independently of cancelling the checklist, but should evaluate the values of the `checklist` and `abortIndex` variables. Configuration: | The screenshot on the right shows the [For each loop](/v1/docs/en/core-for-each-entity-actor) used to process the checklist: - In the **Resolver for entities** parameter, a [Variable](/v1/docs/en/core-storage-value) resolver accesses the `String` list provided in the `checklist` variable, which is iterated over. - A [User callback](/v1/docs/en/core-user-callback-actor) event action is executed in the *action block* of the loop: - The relevant text value for the iteration from the `checklist` list should be output in [Upper case](/v1/docs/en/core-to-upper-case-resolver) as the **Text** for the query. - If a query is confirmed with 'Yes', the next question should appear immediately. The *action block* in the **Yes** branch (left) therefore does not contain any event actions. - If the response is 'No', the processing of the checklist should be aborted. The *action block* in the **No** branch (in the center) contains two event actions: - The [Set value](/v1/docs/en/core-set-value-actor) event action saves the current loop index from the `$index` variable filled by the system in the `abortIndex` variable so that it is 'remembered' for subsequent processes. - The [Break loop](/v1/docs/en/core-break-loop-actor) event action ensures that no further queries are made, but that the event handling is continued with actions below the loop (not in the image). - If the **Max. wait time (s)** expires before a query is answered, event processing should be stopped altogether without an error message appearing. This ensures the [Abort](/v1/docs/en/core-abort-actor) event action is in the **Timeout** branch (right). | ![images/download/attachments/189440306/image-2024-11-28_11-51-55-version-1-modificationdate-1732889618076-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-11-28_11-51-55-version-1-modificationdate-1732889618076-api-v2.png) | | --- | --- | ### More complex use case: Aborting nested loops over several stages An event handling searches all address book entries and company addresses for which read access exists for address contacts with the [Contact type](/v1/docs/en/base-contact-type) 'Building' (`BUILDING`) in order to compile a 'Set' (`Set`) with plain text identifiers for each building, which is displayed in a note. The maximum number of rows output should be limited by a positive `Integer` value in a variable (`limit`). In the following configuration, searching through the address contacts is displayed by two nested loops, of which the outer one iterates over addresses and the inner one over the address contacts within the respective address. As soon as the 'Set' (`Set`) has reached the maximum number of plain text identifiers, the iteration over both loop levels is cancelled and the list of collected building names appears in a notification. Runtime example: The following screenshot shows a notification with a list of three 'building names/numbers', which obviously refer to two different companies: ![images/download/attachments/189440306/image-2024-11-28_11-48-28-version-1-modificationdate-1732889618084-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-11-28_11-48-28-version-1-modificationdate-1732889618084-api-v2.png) **NOTE:** 'Set' (`Set`) is not simply output here as a string, but is cosmetically revised using [Replace text](/v1/docs/en/core-replace-string-resolver), otherwise the usual list notation (`[ , , ]`) would be visible here. Configuration: The following screenshot shows the [For each loop](/v1/docs/en/core-for-each-entity-actor) event action for the *outer loop* and (at the bottom) the [Show alert](/v1/docs/en/freaction-show-alert) event action for the output to be executed after completion or cancellation of the iteration(s). | - The **Resolver for entities** for the *outer* *loop* creates a common list of addresses from two search results (for [Companies/Clients](/v1/docs/en/base-company-account) and [Addresses](/v1/docs/en/base-address)) via the [Collect values](/v1/docs/en/core-collect-resolver) resolver - The *inner loop* receives a specific address as a *reference object* for each iteration of the *outer loop*, which is linked to either a company or an address book entry. - The **Resolver for entities** of the *inner loop* uses a [Plural typed attribute resolver](/v1/docs/en/core-typed-attributes-resolver) to list all address contact attributes with the user-defined **Subtype** 'building' (`BUILDING`) within the address - In the *action block of the inner loop*, a [Concat strings](/v1/docs/en/core-concat-string-resolver) resolver combines information from the parent address (address) and the address data in the address contact (`contactAddress`) to create a 'building name' for the output. - The concatenated text is transferred via a [Modify list](/v1/docs/en/core-modify-collection-actor) event action to the 'Set' (`Set`) provided via the `buildings` variable. **IMPORTANT:** This variable must have been initialized in advance using the [Create instance](/v1/docs/en/core-create-instance-resolver) resolver with the 'Set' (`Set`) type. This list type prevents the addition of duplicates without further precautions. - Regardless of whether the current 'building name' was actually added or ignored as a duplicate, the subsequent [If then else](/v1/docs/en/core-if-then-else-actor) checks the specified *cancellation criterion*: An [Entity property rule](/v1/docs/en/core-entity-property-rule) uses the [Compare with (Form designer)](/v1/docs/en/frebehav-compare-with) compare type to determine whether the specified `limit` matches the current length (`length`) of the `buildings` list. - If the `limit` is reached, a [Break loop](/v1/docs/en/core-break-loop-actor) event action is triggered that ends the *inner loop*. - Below the *inner loop* is another instance of the [If then else](/v1/docs/en/core-if-then-else-actor) event action, which is exactly the same as the previous one in terms of content. This second check is necessary so that the *outer loop* is also aborted when the `limit` is reached. **NOTE:** The *cancellation criterion* for the outer loop does not formally check here whether the inner loop has been cancelled. The check only uses the same *cancellation criterion.* For the outer loop, it is not possible to distinguish whether the *inner loop* was aborted or because the address under investigation contains no further buildings. The [Break loop](/v1/docs/en/core-break-loop-actor) action is also executed in both loop levels regardless of whether a further iteration would take place without cancellation. If required, this can also be checked using the `Boolean` variable `$last` (see [For each loop](/v1/docs/en/core-for-each-entity-actor). | ![images/download/attachments/189440306/image-2024-11-28_11-53-9-version-1-modificationdate-1732889618073-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-11-28_11-53-9-version-1-modificationdate-1732889618073-api-v2.png)![images/download/attachments/189440306/image-2024-11-28_11-54-27-version-1-modificationdate-1732889618071-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-11-28_11-54-27-version-1-modificationdate-1732889618071-api-v2.png) | | --- | --- | ### Special case: Cancelling a loop in a calling event handler In order to be able to define a default process for aborting loops, a [Custom action event](/v1/docs/en/core-custom-action-events) has been set up (*here*: `XF_TERMINATOR`), which can be triggered via the [Dispatch action event](/v1/docs/en/core-dispatch-action-event-actor) event action instead of a direct call of the [Break loop](/v1/docs/en/core-break-loop-actor) event action. Specifically, when a loop is broken, a warning message such as the following should always be displayed if at least one further iteration would be executed without the cancellation. ![images/download/attachments/189440306/image-2024-11-28_15-47-36-version-1-modificationdate-1732889618058-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-11-28_15-47-36-version-1-modificationdate-1732889618058-api-v2.png) Configuration example for the call: | The screenshot on the right schematically shows an event handling with a [For each loop](/v1/docs/en/core-for-each-entity-actor) event action, in which the custom action event `XF_TERMINATOR` is triggered for the loop cancellation depending on a *cancellation criterion* in an [If then else](/v1/docs/en/core-if-then-else-actor) event action. All other event actions are summarized here in [Execute with](/v1/docs/en/core-with-actor) event actions, whose labeling characterizes their significance for the sequence: - The 'loop actions' in the *action block* of the loops are executed for each iteration. This also applies to the iteration in which the [Break loop](/v1/docs/en/core-break-loop-actor) is (indirectly) triggered. - The [If then else](/v1/docs/en/core-if-then-else-actor) event action checks an unspecified *cancellation criterion* as a condition for triggering the custom action event `XF_TERMINATOR` in the 'Then' branch of the case differentiation. The event handling triggered by this (see below) must contain a [Break loop](/v1/docs/en/core-break-loop-actor) event action so that the iteration of the loop is actually cancelled. **NOTE:** The [Dispatch action event](/v1/docs/en/core-dispatch-action-event-actor) transfers all variables from the call context to the data context for event handling calls, including the loop variables (see [For each loop](/v1/docs/en/core-for-each-entity-actor)), which can therefore be evaluated in connection with processes when the loop is broken. On the other hand, changed variable values are not written back to the call context, so that the `$index` cannot effectively be manipulated there simply by assigning a higher value to the variable in the called event handling. - The '... more loop actions' below are also executed for each iteration. However, they are omitted for the iteration in which the cancellation is triggered. - The '... more actions' below are always executed after the loop is completed (with or without cancellation). | ![images/download/attachments/189440306/image-2024-11-28_16-24-11-version-1-modificationdate-1732889618048-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-11-28_16-24-11-version-1-modificationdate-1732889618048-api-v2.png) | | --- | --- | Configuration: | The screenshot on the right shows the configuration for an event handling that maps the default process for a loop cancellation: - A [Custom action event](/v1/docs/en/core-custom-action-events) with the name `XF_TERMINATOR` is used as the **Triggering event**. - A [Static rule](/v1/docs/en/core-static-rule) has been configured as the **Validating rule** so that the following actions are always executed in response to the `XF_TERMINATOR` event. - There are two **Actions on passed rule** configured: - The [If then else](/v1/docs/en/core-if-then-else-actor) event action checks whether the `Boolean` variable `$last` automatically filled in the loop context contains the value `true`. This is only the case if it is the last iteration of the parent loop. - The 'Then' branch of the case differentiation does not contain any event actions, as nothing should actually happen if the cancellation is triggered in the last iteration of a loop. - The 'Else' branch of the case differentiation contains a [Show alert](/v1/docs/en/freaction-show-alert) event action that issues a *notification* of the 'Warning' **Type** if there is a 'significant' break in a loop (before the last iteration). The *value configuration* for the **Message** is shown in more detail below. - The actual [Break loop](/v1/docs/en/core-break-loop-actor) event action should be executed in all cases. It can therefore be found outside the [If then else](/v1/docs/en/core-if-then-else-actor) event action. **NOTE:** There is no point in arranging further event actions below because the [Break loop](/v1/docs/en/core-break-loop-actor) event action is not used here in the context of a [For each loop](/v1/docs/en/core-for-each-entity-actor). These would never be executed, as the control is returned to the parent loop with the cancellation. | ![images/download/attachments/189440306/image-2024-11-28_16-26-16-version-1-modificationdate-1732889618006-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-11-28_16-26-16-version-1-modificationdate-1732889618006-api-v2.png) | | --- | --- | | The **Message** for a 'real' cancellation is defined as shown on the right via the [Value from localization](/v1/docs/en/core-resource-resolver) resolver, which is used here without real access to the [Localization](/v1/docs/en/core-localization-entry) (neither **Bundle** nor **Resource** are named): - The **Default value** defines an English text with parameters to which `Integer` values are assigned below based on automatically provided loop variables (see [For each loop](/v1/docs/en/core-for-each-entity-actor)): - The first parameter (`{0}`) should indicate the iteration in which the cancellation occurred. The value `1` is added to the value of the `$index` variable via the [Simple calculation (+,-,*,/,%)](/v1/docs/en/core-simple-calculator-resolver) value resolver in order to shift the count to the more human-friendly variant with the starting value `1`. - The second parameter (`{1}`) is assigned the `$length` variable, which specifies the total number of iterations. | ![images/download/attachments/189440306/image-2024-11-28_16-34-53-version-1-modificationdate-1732889617999-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-11-28_16-34-53-version-1-modificationdate-1732889617999-api-v2.png) |