Iterate through data sets in workflows

Learn how to use Loop blocks to iterate through data in Retool Workflows.

Loop blocks are useful for automating repetitive actions or performing complex logic on an array of data. A Loop block contains an embedded block that triggers for each evaluated item. This embedded block can query a resource each time or run JavaScript—select either a resource or Run JS Code.

Use value and index to reference evaluated items and their indexes. For example, you can automate emails sent to a list of customers, and customize the message for each recipient, using values like {{ }}, {{ value.first }}, and {{ value.last }}.

The default mode for Loop blocks is GUI. This mode automatically configures the loop to iterate through the query data you select from the Iterable 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 within the custom code.

Loop through data and trigger a query with custom code