Items losing reference of previous nodes

Describe the problem/error/question

I have a complex workflow running and I’ve faced a problem multiple times.
During edit, after the workflow goes past a loop, sometimes it can’t reference previous nodes.

The variable shows up as undefined or sometime I get the error “can’t determine what item to use”.

Considering I have to use the loop node in this case, how can I solve that?

I would love to remove the loop, but I was getting errors all the time without it.

Please share your workflow

Information on your n8n setup

  • n8n version: 1.69.2
  • 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 22.04

Hey @solomon , I do not see anything in the workflow you shared that would not reference an immediately preceeding node. I would expect this kind of problem if you use the default reference by means of .item.. This happens as n8n cannot automatically infer the linked item if there is a branching involved in between. You would have to use other means of referencing the item you need utilizing .first(). instead if appropriate. By doing so, you tell n8n where execatly to look rather than trying to figure it out automatically.

You might want to go over the following docs to comprehend the issue

1 Like

Thank you, @ihortom

I solved it by using a merge node (screenshots below).
But I still would like to understand more about the code node, using the methods described below:

The first method I don’t understand at all.
But I think I got the second method… Does it solve the problem by simply creating a JSON parameter containing the item index?


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