I encountered an error for which I don’t understand the root cause, when using:
{{ $('Combine triggers inputs').item.json.folderName }} in “Google Drive” node (the last)
I managed to fix the error by using .first() instead of .item, but I don’t really understand why n8n would be confused in this case, there is only one Node named “Combine triggers inputs” {{ $('Combine triggers inputs').first().json.folderName }}
Also, using .last() yielded the same result.
I’m just confused about why I needed to change that, I read the doc but that didn’t really tick.
What is the error message (if any)?
Info for expression missing from previous node
An expression here won’t work because it uses .item and n8n can’t figure out the matching item. You can either:
@Vadorequest , when you use .item you delegate inference of the linked item in the previous nodes to n8n. Normally it works fine. However, if there is IF nodes or Switch whereby the set of items gets split, n8n might get confused which item to link the item in the current node.
That is why you might need to give n8n an extra hand and point out to the exact item you want to link to. This is typically achieved by utilizing first(), last() methods and other means.
Hopefully my explanation clarifies the issue a bit.
I guess my mental model of how n8n works is inaccurate, I don’t understand this part.
In my mind, the way it works is similar to how a JS “object” works, each node returns results, indexed by the node’s name. And using $('Combine triggers inputs') should essentially return that result.
Obviously, this oversimplification is wrong.
And I don’t understand what first/last do either, what is the “array” being used underneath?
As there is only one such result indexed by Combine triggers inputs key, the notion of an array and first/last doesn’t make sense to me. But clearly I’m not understanding the true design behind it.
Hey @Vadorequest , I’m going to provide you with the doc links you might want to go through which might clarify the topic further. The most important concept here is so called “Item linking”. In other word, the concept of how nodes reference items in the set of items (array) passed over from one node to another.
→ I have question about use of first.
When your workflow iterate over multiples items, if I use first in it is possible that N8N always references to the first element of the set.? In my case that happend and I had to solve worflow to force the use of. item.
Hey @Adan_Palma , indeed first() will aways refer to the very first item in the set. If the set contains more than one item you would have to resort to some other means.
To make it clearer, using item is fine and it is a default reference when doing drag-and-drop in UI. However, with a complex workflows with branching this could confuse n8n and extra help would be needed to point n8n out to the exact location of the item in question.