I have a workflow which I want to run manually. I have initial “When clicking test execution” node, from which I have two arrows. The intent is to have both of them run (because later on I merge the data they fetch).
However, when I start the workflow with ‘Test execution’, only one of those two nodes run, and the workflow fails in the node where two paths join, with a message “Referenced node is unexecuted”.
How do I tell n8n that I want to walk all the output arrows from all nodes?
load gmail labels in one flow (for a label name → label id lookup)
and load gmail messages in a second flow, then loop over them (in batches of 5, otherwise the flow fails as there is too much data between the nodes) with the following code (that adds new label to each email, so that the following step can set gmail label id for a given message id).
The code:
const allLabels = $('Gmail: read labels').all()
const idFromLabelName = allLabels.reduce((o, label, i) => {
o[label.json.name] = label.json.id
return o
}, {})
const emails = $('Loop Over Items').all()
const assignedLabels = $('Classify email').all()
console.log({emails, assignedLabels, idFromLabelName})
// Loop over input items and add a new field called 'myNewField' to the JSON of each one
emails.forEach((email, i) => {
const assignedLabelName = assignedLabels[i].json.text
email.json.assignedLabelName = assignedLabelName
email.json.assignedLabelId = idFromLabelName[assignedLabelName]
console.log(`Added label ${assignedLabelName} to email "${email.json.subject}"`)
})
return emails; // $input.all();
I was expecting n8n to realize that it executed the first flow up to a point where it needs input from the second one, and so it should run the second flow, but right now the only way to run this flow is to manually click the ‘run’ button for each item in order.
I tried searching from “Referenced node is unexecuted”, which I would expect people with similar problem to run into, but no dice so far, even though this seems like a trivial omission.
Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.
```
<your workflow>
```
That implies to any JSON output you would like to share with us.
Make sure that you have removed any sensitive information from your workflow and include dummy or pinned data with it!
Judging by the screenshot, the lower branch did not run becuase th eupper branch failed midway terminating the whole execution prematurely.
Also I spotted incprrect usage of Loop node. Your loopback connection has to connect the input of the Loop node but it goes to LLM node instead.
Based on your image, when you split a workflow like this, only one branch will run at a time. So the lower branch will not run until the top one has completed and as that is failing at the code node (because the bottom branch has not run yet), the bottom branch won’t run.
Also, the loop needs to come back to the loop node and not the LLM as you have now.
Depending on what you are trying to do, a couple of suggestions:
Split the branches as you have and run the 2 GMail nodes then use a Merge node to bring them both together and see if you can create the rest of the workflow that way.
Another way might be to run your getAll: message node then create the loop after that, incorporating your getAll: label, LLM and Code Node, addLabel Node and Slack Node into the loop. Remember to close the loop back to the Loop node.
Hopefully one of these 2 will get you a little closer.
It is a hacky workaround for n8n seemingly unable to select which of the inputs I want to iterate on, but it works for me.
Is there a better way to do this? I expected the ‘iterate’ step to have a picker of what input I want to iterate on, but it seems to have hardcoded previous’ step’s output as its input.