I’m referencing data from a previous node using $node[…].json, but inside a looped execution it resolves to undefined for some items. Is this due to item linking and execution data scoping?
Describe the problem/error/question
What is the error message (if any)?
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
In n8n, each item maintains its own data lineage. When you access another node’s output, the system tries to resolve the corresponding paired item, not the entire dataset.
If the upstream node changed the item count (e.g., via Split In Batches, Merge, or aggregation), the linkage breaks.
Solutions:
Use:
JavaScript
Copy code $items(“Node Name”, 0, 0) to explicitly access a fixed item.
Or restructure the workflow to maintain item pairing.
This is not a missing field, it’s a data lineage mismatch.