Issue when looping inside another loop

Describe the problem/error/question

Hi everyone! I have bumped into the same issue that was described a year ago but has been closed without a solution:

Shortly, I am trying to loop over items inside another loop but at the second iteration of my parent loop the process does not get inside the child loop.

Basically I have:

Verb Items (set of 3 items): [“eat”, ''drink", “swallow”]
Adjective Items (set of 3 items): [“sweet”, “sower”, “bitter”]
Noun Items (set of 3 items): [“apple”, “juice”, “cake”]

When my workflow first time reaches Done branch of loop for Noun Items it gets looping through the loop of the level above and so on.

Please share your workflow

Share the output returned by the last node

As a result I get:

[{“result”: “eat sweet apple”}]
[{“result”: “eat sweet juise”}]
[{“result”: “eat sweet cake”}]

I expect to result in all combinations:

[{“result”: “eat sweet apple”}]
[{“result”: “eat sweet juise”}]
[{“result”: “eat sweet cake”}]
[{“result”: “eat sower apple”}]
[{“result”: “eat sower juise”}]
[{“result”: “eat sower cake”}]
… and so on

What is the issue and how to achieve desired behavior?

Information on your n8n setup

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

n8n nodes already loop their input items. You probably don’t need your own loops at all.

1 Like

You are right! That was just a simplified demo of what i needed for a project. I was developing a website scraper. But this split out - mostly approach did work great. Thank you!

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