What's up Zapficionados! In this "By Zapier" article I'm going to take a look at Looping by Zapier. What it is, how it works, and some examples of how to use it in your workflows. Let's dive in!
What It Is
Looping by Zapier is a helper app to repeat action(s) in your Zaps a variable number of times for sets of values.
Ok, but what does that mean? Let's use an image to illustrate:
Here you can see that the Zap has a step that provides 4 line items. Using Looping by Zapier, each one of those line items can run through that first action step and the second action step. It's as though the Zap was triggered 4 separate times, except that iteration is happening within the single Zap.
Hopefully that helps to explain what happens when you start the looping process, but how do you get Zaps to produce data that will work with Looping?
How It Works
Here are the various ways you can use Looping by Zapier:
Let's take a look at each of the options:
Create Loop From Text
With this option you can create the line items as follows:
I have 3 fields: Name, Age, and City
On the right-hand side, I add the comma-separated values for that item (you can use something other than a comma, as long as you change the Text Delimiter field).
Let's see what we get when we test the step:
As expected, we get:
Joan, 34, New York
John, 29, Toronto
Janet, 37, Paris
Jack, 41, London
Create Loop From Line Items
Here, I've already got line items from my trigger step. It's just a matter of mapping them accordingly:
When we test it, we see something similar to creating the loop from text:
Create Loop From Numbers
Of all the options, this one is the least obvious in terms of usage, since you don't produce line items that contain information (like the first two options did).
You're essentially creating line items, but the only thing in each one is a number. Based on the screenshot above, you would have 10 line items, with each one being incremented by 1. The starting number is 1. That gives you:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
You could also do something like this:
Again, we start at 1, but this time we go up to 11 and instead of incrementing by 1 each time, we'll do 2. That gives us:
1, 3, 5, 7, 9, 11
My colleague, Clint, wrote an article recently about using Create Loop From Numbers in order to create weekly calendar events. He uses this to loop through Google Sheets rows that are numbered.
Check it out:
What You Can Build With It
In addition to the example above, here are some other ways you could use Looping by Zapier.
Example 1: Looping Through Calendar Attendees to Find and Update Airtable Records
You could trigger on a calendar event, use the attendee emails to perform lookups on each person (in Airtable, for example)
Then you could find the person in Airtable using their email address, and update each person's record with the event name and date.
When the the Zap finds an event that matches my search, it will run through each of the attendees, finding their record and then updating it:
Example 2: Updating Something (Maybe an Invoice) With Multiple Items [Workaround]
There may be instances where an app doesn't have the ability to create line items on an object (invoice, estimate, receipt, etc) but does allow you to update that object. You could first create the object, then update it using Looping and add all of the line items that way.
Example 3: Take Action on Each Item of an eCommerce Order
It's quite common for eCommerce platforms to produce orders that contain line items. As it stands now, if you wanted to create one record in Airtable per item, there would be no easy way to do it. With Looping, you simply do something similar to what I showed above, except instead of finding and updating the record, you would simply create it.
If you're looking more resources about Looping by Zapier you can check out the following:
Community posts about Looping:
As always, if you've got any questions or would like to tell us about how you're using Looping, please feel free to comment below!