Loop actions is an action that runs the actions inside it once for each item in a list (the list can be a set of collected records, or a field that holds several values, such as a list of categories). It's meant to help you do several steps for every item, instead of one step for all of them.
You can use this action for many things, including:
Going through every overdue invoice and sending a follow-up email only when the amount is large.
Building one line per task for a daily summary email.
Note:
The list has to exist before the loop. Collect the records with an action like
Search for recordsfirst. A loop can only go through a list that an earlier action made, a field with several values, or a variable.Loops count toward your run limits. Every action inside the loop runs once for every item. A run can take up to three minutes and use up to 1,000 actions.
A collect action returns at most 1,000 records. The rest is cut off without an error.
Who can use the Loop actions action?
Automations are available on the Free, Plus, and Premium plans. The number of automation actions per month depends on your plan. See the limits for your plan on our pricing page.
To add or change this action, you need to be a workspace admin of the workspace the database app is in. You also need full access to every database the automation uses.
Add the Loop actions action
To repeat actions for each item:
Open the database app and click the automations icon in the top bar (tooltip
Create and view automations). The icon is only there for workspace admins, and not on mobile.Open an automation, or select
New automationand choose a trigger.Add an action that makes a list, for example
Add action→Search for records.Select
Add action→Loop actions. In the list, it readsRun actions for each earlier collected record or for specific field types repeatedly.Next to
for each, check the list to go through. Tape preselects the nearest collection above this action. To change it, open the dropdown and choose another list or field. Without a list, it readsSelect a field.Select
Add actioninside the loop and add the actions that should run for each item.Select
Create automationfor a new automation, orSave changesfor an existing one.
Loop actions settings
The loop reads Loop actions for each Select a field. Below it, the actions that run for each item are listed under Actions.
Select a field: what to go through. The list shows the collections that earlier actions made, and fields that can hold several values. It showsNo resultsuntil you add an action that makes a list. Besides collected records, you can loop over script and calculation results and over fields with several values: categories, people, files, images, email addresses, phone numbers, links, relations, and checklists.Add action: adds an action to the loop body. You can add any action, includingConditional actionsand other loops.
The loop's menu ••• has Settings, Continue statement, Break statement, Continue on error, Deactivate, Turn into, Duplicate, and Remove. Learn more about action settings →
Skip an item or stop early
Continue statementskips the current item. The actions in the loop don't run for items that match, and the loop moves on to the next one.Break statementends the loop. The item that matches still runs the loop's actions once, and then the loop stops.
Both options work with a condition, like a filter. For example, use Continue statement to skip items with an empty email address. Use Break statement to stop once you've found a match.
To set the condition, open the loop's ••• menu and switch on Continue statement or Break statement. A block Continue loop to next if the following conditions are met or Break loop if the following conditions are met appears in the loop. Select Add filter to set the condition.
Use the item inside the loop
Inside the loop, insert values of the current item the same way as everywhere else. Type @ to open the list of variables. For a list of collected records, insert values from Collected / <record name>. They change to the current record in each pass. When you loop over a field with several values, insert the field itself, for example Email. Inside the loop, it holds the current value of each pass, not the whole list.
Actions after the loop
Actions you add below the loop, outside it, run once after the loop has finished. They don't repeat. This is useful for a final step such as sending one summary email after you've processed every item.
Let's look at an example
Let's say your property management team wants a daily list of overdue invoices, with a follow-up email only for large amounts. Here's how:
Set the trigger to
On a scheduled time or intervaland choose every day at 8:00.Select
Add action→Get viewand choose the viewOverdue invoices.Select
Add action→Sort collectedto put the largest invoices first. Learn more about filtering and sorting collected records →Select
Add action→Loop actions. Tape preselects the collection fromGet viewnext tofor each.Inside the loop, select
Add action→Conditional actionsand set the conditionAmount>10000.Inside the block, select
Add action→Send emailand send a follow-up email to the tenant.Select
Create automation.
The next morning, every overdue invoice goes through the loop, and each large one gets a follow-up email.
Tip: If you only need one action for every record, you don't need a loop. Actions like Send email to collected, Update collected, and Comment on collected work on a whole collection in one step.
Nest loops
You can add a loop inside a loop, for example to go through projects, and for each project go through its tasks. Collect the records for the inner loop before it starts, and use Conditional actions to match each task to its project. Learn more about building an HTML table from records →
Loop actions errors
A loop with no list or no actions does nothing. Make sure
Select a fieldshows a list.If the list is empty, the loop runs zero times and the automation goes on. It doesn't fail.
If a script or calculation result holds a single value instead of a list, the loop runs once with that value. To loop over several values, return a list.
If the list comes from an action that sits after the loop, the reference is missing. Move the collecting action above the loop.
If a run stops with a limit message, the loop took too long or used too many actions. Split the work, or process records in batches. Learn more about limits and throttling →
Test, pause, or edit the Loop actions action
Manual runruns the automation once. UnderRun on, select the records, then selectStart run, orSave and start runif you have unsaved changes. Actions in the loop change real records.A simulated run goes through the loop without changing data, so you can check how many items it covers. Learn more about testing automations →
To change the loop, open the automation, change the actions inside it, then select
Save changes.To see what the loop did, open the run. Every action inside
Loop actionsappears once per pass. A pass skipped byContinue statementshows its ownContinue loop to next if the following conditions are metentry instead of the actions.
Learn more
FAQs
Can I loop over the values of a field with several entries?
Can I loop over the values of a field with several entries?
Yes. Select the field under Select a field, and the loop runs once for each value, for example for each email address in a list of contacts. You can loop over categories, people, files, images, email addresses, phone numbers, links, relations, and checklists.
How do I skip an item or stop a loop?
How do I skip an item or stop a loop?
Open the loop's menu ••• and select Continue statement to skip an item, or Break statement to end the loop.
Does a loop count against my action limit?
Does a loop count against my action limit?
Yes. The actions inside the loop run once for every item. Every request an action in the loop sends, to Tape or another service, counts as one action, in every pass. Steps that only work with data in the run, such as Perform calculation, don't count. A run can use up to 1,000 actions.
Why did my loop run zero times?
Why did my loop run zero times?
If the list is empty, the loop doesn't run, and the automation goes on without an error. Check the action that makes the list, for example the filters of Search for records.
Can I put a loop in a loop?
Can I put a loop in a loop?
Yes. Add Loop actions inside another loop. Each level multiplies the number of actions, so watch the run limits.
Are you a developer using the Tape API for automations?
Are you a developer using the Tape API for automations?
The automation API has its own documentation for developers. Full reference: for_loop in the developer docs →
Still have questions? Find answers and get help from community experts in the Tape community →
