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.
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
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?