Skip to main content

Iterate through data with the Loop block

Learn how to run queries for each item in a data set during a workflow.

A new version of the Loop block is currently in beta.

A Loop block contains an embedded block which runs for each evaluated item in an array. You use value and index to reference evaluated items and their indexes.

For example, you can automate a welcome email to new customers and customize the message for each recipient, using values like {{ value.email }} and {{ value.name }}.

Loop models

The default mode for Loop blocks is GUI. This mode automatically configures the loop to iterate through the query data you select from the Loop input dropdown. If you require more complex loop logic, use Code. This allows you to configure the JavaScript code used by the Loop block. You must specify the query data through which to loop using value or index.

The lambda operation is run on each item in the loop input. Operations are generally resource queries but you can also write custom JavaScript.

Loop through data and trigger a query with custom code

Configure block settings

Toggle Retry per iteration or Retry entire loop to configure retry settings for the query that runs for each item or the loop itself.

You can configure the following settings for Response blocks.

Timeout after (ms)

The duration to wait before the block times out. Default is 10000.

Retry count

The maximum number of attempts to retry the query if an error is returned.

Interval

The minimum length of time to wait between query retries. This is useful if a query is triggering a rate limit.

Exponential

Whether to increase the interval between retries, also known as exponential backoff. This is useful for handling rate limits.

Finally

Whether to stop the workflow and return an error if the block fails, or continue to allow an error handler to run.

Coefficient

When exponential backoff is enabled, the constant factor by which the time delay between retry attempts increases after each failure.

Max interval

When exponential backoff is enabled, the maximum time to delay between retries.