I’ve recently learned from this topic that using branches, loops or generating new items can cause n8n to loose reference of the items from previous nodes.
Following on this topic I would like to know more about how to mitigate or prevent this issue, by learning some good practices, because just using first()
and last()
is not ideal most of the time.
I’ve started using the Merge node more often. But I have a feeling there might be a more effective method.
From all the documentation listed below, two things I couldn’t understand were:
$("<node-name>").itemMatching(currentNodeInputIndex)
- Item linking in the Code node | n8n Docs
The first method I don’t understand at all. But I think I got the second method… It solves the problem by simply creating a JSON parameter containing the item index, right?
Documentation I’ve read:
- Item linking concepts | n8n Docs
- Item linking for node creators | n8n Docs
- Item linking errors | n8n Docs
- Output of other nodes | n8n Docs
Information on your n8n setup
- n8n version: 1.71.3
- Database (default: SQLite): SQLite
- n8n EXECUTIONS_PROCESS setting (default: own, main): default
- Running n8n via (Docker, npm, n8n cloud, desktop app): docker
- Operating system: Ubuntu 24.04