Setting the amount of loops for a "loop over items node"

Describe the problem/error/question

I have to delete rows of my google sheet based on specific colum called “expired” if it has any value in it, it gets duplicated to another sheet (a workflow that works perfectly fine). Now Google Sheets is a bit tricky because you can only input the number of the row where you want to start to delete from. I solved this by searching the whole sheet and outputting only if “expired is not empty” and then I use the row value to insert into the delete sheet.

Since the row changes dynamically I have to go back to the beginning and start figuring what is the next row value that can be deleted.

The whole workflow feels a bit like a mess but since I know how many items the true statement of the if node has that is exactly how many times I have to loop over the the whole thing to delete every row that has an expired listing.

Is there a way to get this value into the loop node so it runs as often as it has to, to catch every row that has to be deleted? If somebody can come up with a better approach for the whole workflow I am happy to listen as well.

I tried different recursion models like sending a webhook to trigger the workflow or the start workflow node but both attempts were not successfull.

What is the error message (if any)?

none

Please share your workflow

Information on your n8n setup

  • **n8n version: current
  • **Running n8n via Docker on UBUNTU

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

From what I understand, you want to take out the expired rows and put them into an ‘expired’ sheet, while keeping the rest in the original sheet. Here is a way to do that. It might not be super efficient, but it gets the job done given the constraints.

thanks for your reply! So far I was not able to find a super efficient way to work with google sheets :grin:

The problem is the original sheet get´s bloated really quick with a lot of expired listings especially when vendors delete and reupload their listings. Your approach certainly attacks the problem from a different angle thanks for your idea!

Sure! To be honest, I feel like the Google Sheets node is lacking. A better way to do this would be to simply ‘Delete all cleared rows’, which would alleviate the need for the sheet swapping. I’m not sure if that’s a limitation of the API or of the node itself. At some point, I will try to investigate that.

1 Like

make.com has the same limitation you can only delete based on row number which changes dynamically … I tried to lookup their API documentation so I could potentially send an API request instead of using the node but that opened up more problems that it solved, for me at least.

1 Like

Just to update you on this–I did find a way to delete empty rows using the API and have submitted the change. Hopefully it will be merged into the next version of n8n :sunglasses:

2 Likes

not all heroes wear capes, this makes things a lot easier for me!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.