For Each
This action lets you execute one or more actions for each item in an array.
Here are details about this action's parameters:
Parameter Name | Description |
---|---|
items | An expression that evaluates to the array that is to be looped. |
item | The default alias for the current item in the array; can be changed as desired. |
index | The default alias for the index position; can be changed as desired. |
mode | Defines whether the actions are run serially (default) or in parallel. Regardless of the mode, the For Each action does not complete until the actions for each item in the items array are complete. |
The "mode" parameter allows for serial or parallel action. The default is serial, for which each "actionId" call is only made for an item when any previous item's "actionId" call finished (meaning, any Promise returned from the last action resolves). Using "parallel" means that each "actionId" call does not wait for the previous call to finish (useful for Rest Action calls, etc). Using either mode, the For Each action does not finish until all Promises returned from the "actionId" chain resolve (if no Promise is returned, it is considered resolved on return).
The following table describes additional properties injected into the available contexts that the called action ('callee') can reference in its parameter expressions:
Parameter Name | Description |
---|---|
$current.data | The current array item. |
$current.index | The current array index. |
alias.data | An alternate syntax for $current.data , which allows a reference to $current from nested contexts.
|
alias.index | An alternate syntax for $current.index , which allows a reference to $current from nested contexts.
|
Return Values
On success, an array is returned with each element containing the return value from the last action in the loop, from each iteration. For instance, if the loop contains two actions that return results, actionA → actionB, and the loop iterates 5 times, the returned array will have 5 elements, each corresponding to an iteration and containing actionB's result from that iteration.