Execute a set of actions for a predefined number of times.

Overview

The For Loop action allows you to execute a set of actions repeatedly for a specified number of times or over a collection of items. This action is useful for iterating over a collection of data or performing a set of actions a specific number of times.

Accessing Action Output within a Loop

When you use actions inside a For Loop, each action’s output can be accessed as if it were an array. This feature allows you to retrieve data from any specific iteration of the loop.

To access the output of an action in a specific iteration, use the following syntax:

  • For a fixed iteration (e.g., the first iteration): {{$action.actionName[0].outputField}}
  • For the last iteration: {{$action.actionName[-1].outputField}}

Here, actionName is the name of the action, and outputField is the specific field in the output you want to access. The index 0 refers to the first iteration, 1 for the second, and so on. The index -1 always refers to the last iteration.

Learn more about this syntax and indexing variables in our Variables Documentation.

Example

Output

{
  "$action['Count-to-Ten']: {
    "i": 9 // Last run iteration of the loop
  }
}