Skip to main content

Workflow blocks

Learn about blocks for interacting with data in Retool Workflows.

A block is a piece of code, such as an SQL query or JavaScript statement, that runs within a workflow. Each block type has a different function and allows you to build complex automations.

How blocks work

You drag and drop blocks in the Workflow IDE, then configure them to interact with data or perform actions. You connect blocks together to define the control flow which determines the order that each block executes. Blocks can reference the results of previous blocks that have already executed, passing along the results to the next block.

You can also configure functions that are blocks which do not run as part of the control flow. As with JavaScript functions, a workflow function is only run when called.

Block model

A block is a type of query that interacts with data (e.g., querying a database) or performs an action (e.g., execute JavaScript code). Blocks are modular and have internal state—you can reference block properties in any subsequent block. For example, a block named findUser can be referenced using findUser.data.

A block referencing data from a previous block

Logic-based blocks, such as the Filter block, iterate through items within a block's data. Instead of referring to a block's data with data, you would select the block to iterate through. You then reference each item using value or its array index with index.

Filter results based on the item's index

You can write JavaScript almost anywhere in Retool using {{ }} and component property values are available globally. This makes it possible to reference other properties when configuring a value.

All workflows contain a startTrigger block. This is the starting point for a workflow and controls how it triggers, either on a schedule or with webhooks.

The startTrigger block

Settings

You can configure a number of settings for blocks. The settings available depend on the type of block and resource currently in use.

Comments

You can add comments—with support for Markdown—to blocks to explain their function for other users. Click Add comment in a block and write a comment.