I recently stumbled into the error [ERROR: Can’t determine which item to use]
It was probably caused by a switch in the workflow. In one case, I solved it using first().
AFAIK, it should get the first item from the output of a node. But the “problem node” was always outputting a single item.
So, why does first() work while item doesn’t work?
yes, usually it only happens on a certain time, it will not always happen
usually, when you use item and then you trigger, it will able to detect and identify which item to refer to or you can execute untill before the error node, and it should be able to identify which item to use
yes, it will always work correctly
Yes, one of the cause can be that, also if u use a ‘multiple branching’ type of node like merge node, switch node, if node, that can also happen or like 1 node but you also connect it to multiple node
Hey @albertocv,
I would say use first() whenever you explicitly want to grab the first item from an output. E.g:
Sometimes an API returns multiple items and you are only interested in the first one. Imagine a search API that returns a list of results but you are pretty sure your query yields only one result.
As mentioned here, if the thread that links output items back to their source items is broken or ambiguous, and you cannot use $item
If, for any other reason, you are only interested in the first item. Example can be fetching weather data from OpenWeather API, where primary weather conditions are always first (and most of the time the only) element in weather array.
Hopefully this clears it up a bit, but please follow-up if you have any more questions.
Hey guys I have a question. I ran into the same issue today. The problem is not that first and last doesn’t work for me it’s more that my node code god multiple outputs and if I use first or last it always takes only 1 output as the value instead of all. Any way to fix this?
Hi there @Mesh , if you can make a new topic or question and in there share your workflow or your code node and tag me or send me in private the link, i can definitely help you check it
its easier to track it as a question on its own rather than a comment
Hello @albertocv , do we help answer your question, if so, please mark one of our answers that helps you as the solution, as it would greatly help the community