Best answer

Loop Not Removing The Expected Number Of Rows From Spreadsheet

  • 22 November 2021
  • 3 replies
  • 65 views

Hi everyone, 

I’m trying to add data to a Google Sheet and then email a copy of that sheet twice per day, and clear all the rows every time the sheet is sent.

Everything seems to work fine except the loop that deletes the rows doesn’t work properly every time. 

If I test it with only 5 or 6 rows, it clears all the rows. If there are more rows (in the example below, there were 19) then it seems to only clear some of the rows, leaving a couple at the end. In this example, 3 were left. In some tests, it has deleted all the rows.

The zap does a bottom-up search to find the first line that contains “New” in the Internal Use column. It then uses that line number (in this case, 20) to know how many times to loop.

 

The loop settings:

 

As mentioned, it seems inconsistent. Sometimes it deletes everything. Then on some runs, it leaves a few rows at the end.


Any ideas?

icon

Best answer by jesse 19 July 2022, 22:44

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

In the zap history, the correct number of loops seems to be running, so I can’t understand why the rows are not being cleared.

Userlevel 7
Badge +14

Hi @BradZA 

Try adding a Delay After Queue step in the Looping: https://zapier.com/help/create/customize/add-delays-to-zaps#delay-after-queue

 

If you open a ticket, Zapier Support can look into this further for you: https://zapier.com/app/get-help

 

Alternative is to use Airtable instead of GSheets as the operational database: https://zapier.com/apps/airtable/integrations#triggers-and-actions

Userlevel 7
Badge +9

Hey folks! Just coming in here to close the loop after reading through a related support ticket:

At a glance, I'm wondering if it would be more reliable to map the loop iteration number as the row to be deleted, rather than looking up the row and passing the row ID.
 
3c92b77fdde1c9d708db65cfc4ff64ea.png
 
Would you be able to test out that updated setup?
 
Another option would be to add a Delay after queue step after step 8. https://zapier.com/help/create/customize/add-delays-to-zaps#delay-after-queue

Delay after Queue will ensure the subsequent steps will run in sequence and not in parallel.
 
Both of these solutions would hopefully prevent a timing issue where the deleted row or row that's found in the search step isn't processed by the time the next looping iteration begins.