Skip to main content Skip to complementary content

Loop block

The Loop Block allows iterating over items in a list. This is handy when you want to process items (records) one by one.

The Loop block.

The Loop block.

All the blocks inside the Loop will be executed multiple times, depending on the number of items in the list.

You can use the block Exit loop to stop processing the items in the loop, e.g. in combination with a Condition Block.

The Exit Loop block.

The Exit Loop block.

Note that list blocks (where the output is a list) have a built-in loop, which acts the same way, and avoids the need to add a separate loop block. Example:

A List Contacts block has a built-in loop.

A List Contacts block with an Output block in its loop.

See also Using Loops.

Placeholders to access the item in the loop and the index

The input of the loop block should be a list. Inside the loop you can use the placeholder { $.loop.item } to reference the current item from the list that is being used. Example:

An Output block in a loop.

A Loop block containing an Output block. The Output block is selected. The Data to output is set to Loop > Item.

Same example in raw view mode:

An Output block in a loop, with raw code.

As above, but in raw code.

Index

The placeholder { $.loop.index} can be used to get the index of the current item, starting with 0 for the first item (0, 1, 2, 3...).

Iterate over keys of an object

Note that you can also iterate over the properties of an object with key/values. In this case the placeholder { $.loop.item } will give you the value of each property, and { $.loop.index} will give you the key of each property. As always, these placeholders should only be used inside the loop.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!