Trouble with multiple inputs not iterating

First question, lmk what I can do better next time.

My workflow checks multiple google sheets dynamically. It generates the file name (according to convention) from a name slug in a different file. In this case it is outputting 3 files reliably.

The next node receives the 3 different IDs and still runs 3 times, but only ever references the id of the first entry. The preview of the “document by ID” box even shows all 3 unique IDs. I have tried referencing the doc ID with what is show in the box and just with {{ $json.id }} but it keeps only running the first node and accessing the same doc 3 times.

I’m fairly new and still plentifully confused by looping, merging, and splitting, but this node is literally just linear and from what I understand supposed to reference each input item individually.

“Get today’s content items” receives 3 unique IDs and only ever uses the first one.

Thank you!

After "Find Quartely Calendar” node, add a split or code node.

What’s going wrong

In Get today’s content items, the Document → By ID field uses:

{{ $('Find Quarterly Calendar for Client').item.json.id }}

That .item call defaults to item 0 (the first result), so even though the node runs 3 times, it keeps using the first ID. The screenshots in your post show exactly this setup. n8n Community

Two clean ways to fix it

Option A (simplest): Use the current item ($json)

Each input item to Get today’s content items already has the id from the previous node. So just bind the field to:

{{ $json.id }}

Run the node—now it will use each item’s own id (3 inputs → 3 different IDs). Your upstream node indeed outputs 3 different ids. n8n Community+1

Option B (if you really need to reference that other node)

Tell n8n to use the current item index:

{{ $('Find Quarterly Calendar for Client').item($itemIndex).json.id }}

Using $itemIndex aligns the item from the referenced node with the item currently being processed, so iteration works as expected. n8n Community

Quick checklist

  • Document → By ID: set to an Expression (fx icon on). n8n Community

  • Prefer {{ $json.id }} whenever the value already exists on the incoming item. n8n Community

  • Make sure Execute Once (node → Settings) is off so the node processes every item. (General n8n gotcha, not visible in your screenshot.)

I started with {{ $json.id }} and it was doing the same thing, so I switched to trying to access the previous node by name.

Using {{ $(‘Find Quarterly Calendar for Client’).item($itemIndex).json.id }} just gives the error “Can not get sheet ‘By ID’ with a value of ‘undefined’”

Just now I switched it back to {{ $json.id }} and it does the same thing - it still runs once for each client but it uses the same ID each time. I even checked the JSON coming in and they are all unique.

To what end? The input from the “find clients” node is a simple json with 3 unique IDs and names.

I put it in a loop node. Shouldn’t need it so I’m annoyed but it’s alright.

1 Like

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