Loop node is not working as expected when its run for the second time

When the second set of data enters the loop node, the loop does not occur; instead, it goes to the ‘done’ node.
How can I fix this so that whenever data passes through the loop node, it gets written to Google Sheets? For instance, when I set a data set of 5, it loops through all 5 items perfectly. However, when the initial node is called a second time, the loop does not happen.

I would like to know right approach to do this :slight_smile:

What is the error message (if any)?

In done branch , i could see lots of “[undefined] [undefined][undefined]”

Please share your workflow

Information on your n8n setup

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

@salsiy , you don’t need the IF node to check if the looping is complete. It’s totally redundant and unnecessary. If you want to start over with a datastore, use the “done” output of the loop. However, you should ensure that the loop doesn’t become endless unless the datastore node eventually returns nothing, thereby stopping the workflow (generally speaking).

Specifically to your workflow, this is what should do

@ihortom Thanks for the reply , im putting my actual workflow , so you will have more clarity on what im trying to acheive. when data enters the loop block for second time its not processing as expected , maybe im doing the wrong way. Here is my complete workflow

@salsiy , thanks for the fuller picture. As I cannot run your workflow I might be wrong. However, I would not use Loop in this case at all. What you need is a pagination technique for GraphQL node.

For clarity, here’s what I mean. It’s just a visualization of the concept to give you an idea, not a working workflow.

You just need to figure out the changes needed for the nodes in the yellow square. You might need to add IF in there and some other transformation but it should be doable.

If you have never done pagination before, please, refer to this document, The Good, the Bad, and the Ugly of looping with n8n – n8n Blog,

@ihortom Sure , thanks. I will look into this and post the update :slight_smile:

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