While (Activity)


  • Purpose: To repeatedly execute a set of activities as long as a specified condition remains true.

  • Functionality: The "While" activity implements a "while loop" structure. You configure it with:
    • Condition: A boolean expression that is evaluated before each iteration. The loop continues to execute as long as this condition is true.
    • Loop Body: The set of activities that will be repeated as long as the condition is true.
    • It's crucial to ensure that the condition will eventually become false within the loop body (or in external factors) to prevent infinite loops.

  • Use Cases:
    • Condition-Based Repetition: Repeating actions until a specific state is reached or a condition is no longer met (e.g., retry an operation until it succeeds, poll an external system until data is available, process messages from a queue until it is empty).
    • Dynamic Iteration Counts: Looping when the number of iterations is not known in advance and depends on runtime conditions.
    • Event-Driven Looping: Repeating actions based on external events or changes in data that affect the loop condition.

How to Use Looping Activities:

1. Drag and drop a Looping activity (e.g., "For", "For Each", "While") from the Looping section onto your workflow canvas.

2. Configure the properties of the chosen looping activity:

  • For For: Set the iteration count.
  • For For Each and Parallel For Each: Specify the collection to iterate over.
  • For While: Define the loop condition (a Boolean expression).

3. Drag and drop the activities you want to repeat inside the body of the looping activity. This defines the "loop body" – the set of actions that will be executed in each iteration.

4. Use the "Break" activity within the loop body if you need to implement conditional loop termination.

5. Connect the Looping activities within your workflow to integrate iterative processing into your automated processes.

6. Save and activate your workflow. When executed, the looping activities will control the iterative execution of the workflow logic as configured.


Benefits of Using Looping Section:
  • Automated Repetitive Tasks: Efficiently automate tasks that need to be repeated multiple times, either for a fixed count or based on conditions.
  • Collection Processing: Easily process collections of data (lists, arrays, datasets) by iterating over them and performing actions on each item.
  • Improved Workflow Efficiency: Looping structures reduce the need to manually duplicate activities for repetitive steps, making workflows more concise and maintainable.
  • Conditional and Parallel Processing: "While" loops enable condition-based repetition, and "Parallel For Each" allows for potential performance gains through the parallel execution of loop iterations.
  • Dynamic Workflow Logic: Looping activities allow for more dynamic and flexible workflow logic that can adapt to varying data sets and runtime conditions.

By utilizing the Looping section activities, you can create powerful and efficient workflows in ELSA that can handle iterative processes, data collections, and repetitive tasks with ease, enhancing the automation capabilities of your applications.