Zapier Loop Through Line Items Example

The Zapier loop through line items action is a godsend! For those of us who have been duct-taping together ways to loop through Google Sheets in Zapier, this action finally simplifies the process of looping through line items. Now you can perform tasks in bulk for each row in your sheet easily and quickly so you can get back to the important stuff!

This post will give an overview of the Zapier loop through line items action by using a Google Sheet of customer delivery information to send SMS and email alerts to customers if their order has been shipped. So without further ado let’s take it away!

Diagram of the Zapier loop through line items action
Flow diagram of line item looping in Zapier

Get Line Items from Google Sheets

Image showing the schedule trigger used to pull line items from Google Sheets into Zapier for looping
Pull in line items for looping according to a schedule

The Customer Database sheet contains the First Name, Order #, Email Address, and Phone Number of each customer along with the Delivery Today? checkbox field to designate whether their order will be delivered today.

Customer database Google sheet containing line items to loop through in Zapier
Customer database Google sheet

As explained in the Zapier Google Sheets Quick-Start Guide there are a few different options for importing data from Google Sheets into Zapier depending on the number of rows or the amount of data that you want to import.

For this example, it is only necessary to import a small number of rows meaning the “Find Many Spreadsheet Rows” action from the Google Sheets app can be used. As shown in the images below, when the “Lookup Column” is set to the “Delivery Today?” column and the “Lookup Value” is set to TRUE then only the rows where this condition is matched will be pulled into the “Rows Col$” fields.

Image showing the setup of the Google Sheets action to read in information from the customer database
Google Sheets action setup
Image showing how the columns from the customer database Google sheet can be accessed when using the "Find Many Spreadsheet Rows (With Line Item Support)" method
Google Sheets columns available as inputs for looping when using the “Find Many Spreadsheet Rows (With Line Item Support)” method

Need to read in more than 10 rows at a time? Explore the different options available in the Zapier Google Sheets Quick-Start Guide post so that you can choose the best option and know how to format the imported data correctly so that it can be used in subsequent actions.

Zapier Loop Through Line Items Workflow

Overview of the Zapier loop through line items workflow
Zapier loop through line items workflow

Zapier Loop Through Line Items Action

Now that the customer information has been brought in from Step 2. each of the column values can be used in the “Values To Loop” section to form array variables, which we can then loop through. Make sure to select the “Looping by Zapier” app and the “Create Loop From Line Items” action event.

Note the 500 iteration limit that is imposed on the “Maximum Number Of Loop Iterations” field. If you have more than 500 rows to loop through then you will need to use a nested loop (see the Zapier For Each Loop Quick-Start Guide).

Setup of the Zapier loop through line items action
Zapier loop through lines items action setup

Once the looping variables have been setup in Step 3, they can then be used in subsequent steps to supply a different value for that variable for each iteration of the loop.

Send Email for Each Line Item

Image showing the body of the outbound email populated with the looping variables
Email body populated with line item information

Send SMS for Each Line Item

Image showing the body of the outbound sms populated with line item information
SMS populated with line item information

If you want more information on how to get started with sending SMS with Telnyx, take a gander at the Marketo 2 Way SMS using Telnyx and Zapier post.

One thing to note about sending SMS is that there are rate limits that apply to certain number types so if you try and exceed these limits, which is very likely when you loop through arrays, then the carrier will throttle the messages and spread them out over a longer timespan to ensure delivery. Therefore, do not expect all your SMS to be delivered right away when looping.

This throttling is implemented to prevent fraudsters and bad actors from easily being able to spam people with large amounts of SMS at once. If higher rate limits are needed you can get verified by your carrier who can then increase your rate limit or allow you to purchase another number type with higher throughput e.g. a short code number. If you want to learn more about rate limits and the pros and cons of the different number types then take a look at the Marketo SMS Marketing with Telnyx post.

Post Loop Follow Up Actions

You might have been wondering “What if there are actions that I only want to do once after the loop has ended?”.

This is where the “Continue Once Loop Complete” filter comes into play. It uses the “Loop Iteration is Last” boolean value to check if there are any more iterations of the loop to complete. Once this value is true then this filter will allow the Zap to progress to the remaining steps which will be executed once only.

Filter  setup to only allow progression once the Zapier loop through line items action has finished
Filter to only allow progression once Zapier has looped through all the line items

Notice how the content of the email and SMS summary messages is populated using the columns from Step 2 rather than one of the loop variables from Step 3. As shown in the email and SMS inbox images below, this results in one single summary email and SMS being sent containing all the customer information for orders that will be delivered today.

Summary email populated with row information from Google Sheets
Summary email populated with row information from Google Sheets
Gmail inbox showing the summary email and emails for each line item
Gmail inbox showing the summary email and emails for each line item

N.B. You’ll notice from the image above and the screenshot of the SMS messages below that the emails and SMS messages do not get sent in the expected order. If the order that the for loop executes in is important to you and you need email 3 to be sent before email 6 then take a look at using webhooks or delays.

Summary SMS populated with row information from Google Sheets
Summary SMS populated with row information from Google Sheets
SMS inbox showing the summary message and messages for each line item
SMS inbox showing the summary message and messages for each line item

What’s After Looping Through Line Items?

The Zapier loop through line items action is great but there have been 2 big limitations identified while we were working through this post:

  1. Not being able to pull in more than 20 rows from Google Sheets at once
  2. Not being able to loop more than 500 times

As always I’ve got you’ve covered 😉

  1. Zapier loop through array from Google Sheets
  2. Zapier loop array with nesting

Leave a Reply

Your email address will not be published. Required fields are marked *