URGENT: Problem with Loop in Loop Causing Incorrect Data Access and Duplicates

I have nested loops in n8n. The inner loop can’t properly access items from the outer loop due to index mismatches. This causes duplicate labels and wrong data being used. How can I handle nested loops correctly so each iteration gets the right data?
In my case the large loop (image to the left) obviously passes on one item but within that loop the Code node Extract Proposed Labels creates 1-3 items and the second loop I have tried to reference them with $json. or .all()[$itemIndex].json.Link … in every case it does the same thing for the number of runs that was passed on from the first loop. How can I solve that to reference the actual item from the first loop and not always the first?

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

Hi, why don’t you use a sub-workflow

Reg

J.

Hi there,i would love to help your issue here but im not sure i understand the problem here? what item? which node should fail or be incorrect?

@fahmiiireza @jcuypers the one that is not properly working (looking at the image) is everything on the top right… say we have a loop with 10 items it accesses the same values 10 time or doesnt access anything at all depending on what I put in… thats the main problem. Its a split in batches loop within another one.

Solved it myself.