ForEach

Overview


This block is a loop – a structure that’s executed repeatedly.

Loops make it easier to perform the same action for each element from a list. A single series of actions is called an iteration.

ForEach doesn’t do anything by itself. You should put other blocks above the End For line, which is the ending of the ForEach block, in order to create a pattern.

The ForEach block has a field that must contain an array. Arrays are initialized with [*], where * is the content that you want to list. Elements are separated by commas.

Iterations start with the first element from a list (index=0), and continue until the last element of the list (index=(n-1)), where n is the total number of elements.

Drag ForEach and drop it inside a workflow where a green field appears. Doing so makes it a part of the workflow.

When you start typing a ForEach item in the Editor, its type is automatically taken and autosuggested accordingly:

Procedure

ForEach works well with Assign.

  1. Enter information in the List field.

  2. Set Assign according to the actions you want executed.

  3. Run the workflow to see the effect applied.

The resulting structure will execute sequential iterations for each item listed in the array. The number of iterations is the number of items you have provided.

Refer to the current element of the iteration by typing $Name.item, where “Name” is the name of the ForEach block.

To disable a ForEach block without deleting it, use the slider on the left of its name.