Add a For each loop step to a workflow

Use a For each loop when you have a known list of items to process from an earlier step. The loop iterates over each item in the collection and executes the loop body for each one.

Before you begin

  • You have access to the workflow builder.
  • The workflow has a trigger step and is in an editable state.
  • An earlier step produces a list of items.

Procedure

  1. Navigate to the Workflows page and select the workflow you want to modify.
  2. Click Add step > Logic > Loop.
  3. In the Type field on the Parameters pane, select For each.
  4. In the Items expression field, enter an expression that resolves to a list of items. Use the expression syntax to reference output from a previous step, for example: ${previous_step.server_list}.
  5. Optional: In the Item variable field, enter a custom variable name for the current item. The default is item. Steps inside the loop body reference this value as ${loop.item}.
  6. Optional: In the Index variable field, enter a custom variable name for the current iteration index. The default is index. Steps inside the loop body reference this value as ${loop.index}.
  7. Optional: In the Max iterations field, enter a maximum number of iterations. This acts as a safety limit to prevent infinite loops. If you do not set a value, the system applies a default limit.
  8. Optional: Select the Settings tab and configure the On failure behavior:
    • System default: Uses the system-wide setting configured by an administrator.
    • Continue on failure: The loop stops and the workflow continues to the done path.
    • Stop workflow or branch on failure: The loop stops and the workflow fails.
  9. Click Create or Update to save the step and add it to the canvas.

    A Replace this step to complete the loop placeholder step appears next to the loop step.

  10. Click the placeholder step to open the Add step panel. Select the steps you want to add to the loop.
  11. Click Save to save the step to the canvas.
  12. Click the step you added to the loop to open its configuration. Reference the current item inside loop body steps using ${loop.item}. To reference the current iteration number, use ${loop.index}.
  13. Verify that the last step in the loop body connects back to the loop step. This connection creates the loop cycle.
  14. Connect the Done output of the loop step to the next step that runs after the loop completes.
  15. Click Save to save the workflow.

Results

  1. Run the workflow manually or wait for the configured trigger to start it.
  2. Monitor the workflow run and confirm that:

    • The loop body executes the expected number of iterations. The loop step displays an iteration count badge on the Loop branch handle. The badge shows the current iteration number during execution and the total count when complete.
    • The loop completes and the workflow continues on the done path.
    • Downstream steps can access the loop output, including iteration_count and iteration_results.
    • In the execution detail activity table, each iteration appears as a separate row with the iteration number.
  3. In the execution detail view, confirm that the taken branch handle displays a green border with a checkmark. Skipped path edges display as dashed lines, and skipped downstream steps display with a dashed status icon.