How to use Looping in Automations
  • 16 Aug 2024
  • 1 Minute to read
  • Contributors

How to use Looping in Automations


Article summary

Learn how to use looping in Automations.

What is Looping?

Loops, or looping, repeatedly executes a set of logic until a specified condition is reached (in this case reaching the end of a list). In Automations, loops are provided a list of items. The loop will go through each item in the list, performing logic until it reaches the end of the list. For users familiar with programming, this is the same as a for-each loop.
Screenshot 2024-05-09 at 7.30.19 PM

How to use looping in Automations?

Click Automations in the navigation bar and then click +Create Automation or edit an existing automation. This will open the Automations editor.

In the automations action menu, click on the solid lines to select looping. Once the looping block has been opened, you'll need a list to enter into their loop. You can either manually create a list (for example, ["a","b","c"]), or use a Connector Function to return a list.

List

If an empty list is passed into the loop, it will return null and not run.

Two variables will automatically generate to use within the loop. The first variable, position, denotes the current iteration of the loop within the list and starts from 0 as the first position. The second variable, element, provides access to the current item in the list.

Screenshot 2024-05-09 at 7.20.56 PM

For example, you can use ["a","b","c"] as the list for your loop and create/update table as the logic performed in each loop. Here's a breakdown of the steps:
Screenshot 2024-05-09 at 7.09.35 PM

What's happening in this example is:

  1. The loop would go start with 0 as its position, "a" as its element, and then create/update the table.
  2. The loop would go to 1 as its position, "b" as its element, and then create/update the table.
  3. The loop would go to 2 as its position and "c" as its element, and then create/update the table.
  4. The loop would end.

The timeout is a minute for each automation. To learn more, read Automation Limits.

Further Reading


Was this article helpful?