By Zapier: Learn About Looping

  • 20 September 2021
  • 0 replies
  • 68 views
By Zapier: Learn About Looping
Userlevel 7
Badge +10

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:

a4422c5cc853b93a559e2818d88381f9.png

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:

g9zflIoEHD0lB4PGVMyoWXiKPoCo401TtSYI01IENiWEvIIVMYvOBoBjIPOztRpGqL6KDC68FONwxcZ-jaf9fo5jJbBQNIrTjSxm1L9guotUYVO4Gl3glw7wO-t66rSuYVh82Uu2=s0

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:

48959056c639819c9dd88b093f10b539.png

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:

eda781913eae741c3e908d111e781976.gif

As expected, we get:

  1. Joan, 34, New York

  2. John, 29, Toronto

  3. Janet, 37, Paris

  4. 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:

370db44124fc93ced536b833a64e4121.png

When we test it, we see something similar to creating the loop from text:

cfbeb73e667ad83e89865acb2628df6a.png

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). 

ae554fbebb62d4e13cd1b77779e5b46c.png

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:

d42d53e3054b25d3c647904c2a830d29.png

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:

https://community.zapier.com/featured-articles-65/using-looping-by-zapier-to-create-weekly-calendar-events-11161

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)

12673f70ccec1911e852aca7f128b265.png

Then you could find the person in Airtable using their email address, and update each person's record with the event name and date.

086ed96a8d0a8f3d519a53e5049eccb3.png

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:

9fa6cc8328f9b7b3ff2b9c599cc88433.gif

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. 

Wrapping Up

If you're looking more resources about Looping by Zapier you can check out the following:

  • Zapier help docs

  • Community posts about Looping:

    • https://community.zapier.com/zapier-announcements-10/the-editor-now-shows-looping-by-zapier-steps-in-a-more-intuitive-way-9100

    • https://community.zapier.com/featured-articles-65/retrieve-existing-items-from-an-rss-feed-and-store-them-in-airtable-10461

    • https://community.zapier.com/tips-and-inspiration-5/using-looping-and-digest-in-one-zap-8805

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!


0 replies

Be the first to reply!

Reply