Loops
What is a loop?
A loop is a workflow structure that allows you to repeat a series of actions multiple times. It consists of a start point and an end point that connects back to the start, creating a circular flow of operations. Loops are useful when you need to perform repetitive tasks, process items in a collection, or continue an operation until a specific condition is met.
Loops in a workflow are achieved via the Trigger Workflow components.
Before you begin: avoid infinite loops
An infinite loop can be created if your loop only contains automated actions without any tasks, time delays or conditional paths and logic to exit the loop. An infinite loop will keep running over and over again until you run out of actions.
❌ Example of an infinite loop
Below is an example of an infinite loop. This is because the API component will run automatically and trigger another loop over and over again.
✅ Example of an non-infinite loop
This is an example of a loop that will not result in an infinite loop run. This is because the assign task will pause the loop until it is submitted and before the next loop begins.
Before performing a run or test run of a loop, understand how to stop a test run or workflow that is stuck in an infinite loop.
If you are unsure, simply place a time delay component with a delay of a few minutes before the end of the loop - this will give you time to terminate the loop manually if it does result in an infinite loop.
How to create a loop
To create a loop in a workflow, place a Trigger from Another Workflow component at the start of the loop. Then place a Trigger Another Workflow component at the end of the loop.
Go to the end of the loop, and click into the Trigger Another Workflow component. Turn on the Loop Mode switch at the top of the Trigger Another Workflow component. Select the start of the loop (the Trigger From Another Workflow component you added previously).
Select the placeholders you want to return from the end of the loop back to the start of the loop.
Go to the start of the loop, and turn on the Loop Mode switch there as well and select the end of the loop.
The loop has now been configured and is ready to test.
Adding loops to existing workflows
If you have an existing workflow and want to add a loop into a section of it, you can do so by combining the loop start (Trigger from Another Workflow) to a Merge Workflow component. Connect the existing workflow into the Merge component and configure it to run if either the loop start or non-loop component is run.
In the example below, this workflow can be triggered by the form, and then can also be triggered again by the loop start:
Configuring loop and exit conditions
Combine the branch paths and conditional workflow components with the loop end (Trigger another Workflow) to control whether the loop continues or stops. In the example below, we use a branch paths with a conditional path that will continue the loop if a certain conditional is met (e.g. if loop = true) and another which sends a slack message and does not run or re-run the loop.
Always include at least one exit condition in your loop to prevent infinite execution.
Running loops
When the workflow above is run, the end of the loop will then trigger another session to be created, starting the loop again. Each run of the loop will be contained within its session.
How to stop an infinite loop
Before you run a loop, make sure you understand how to stop a loop if it gets stuck in an infinite loop.
To stop an infinite loop in a test run, disconnect either the connection after the loop start (Trigger from Another Workflow) or into the loop end (Trigger Another Workflow) components.
To stop an infinite loop in a production run, unpublish the workflow.