Describe the problem/error/question
My goal is to merge multiple runs’ items into one run containing all individual items into a single list. I followed this example workflow. But the problem with this workflow is that if I use the Merge loop items
Code node directly after a node that returns multiple runs, the merging works but the Code node then returns multiple runs too. To make this example work, you have to make the code node run for a single run done in previous node and the single run should be the last run of the previous node too (the example workflow also did this). In my example workflow you will see that I am trying to merge the runs of NoOp1
node using the Code
node, but then the Code node returns 4 runs appending items in each run (notice the screenshot of output). For a workaround I am trying to return the last run using an If node and then run the code node for that last run so that it gives me the combined list of all runs (I have attached the workaround workflow code too).
What is the optimal solution to merge the runs into one run or if possible how do I get the last index of total runs executed in the previous node so that I can implement the workaround way dynamically instead of a fixed run value?
Thank you.
Please share your workflow
An example flow reproducing the problem:
Workaround flow where I use an if node which returns true for the last item and this lets the last Code node run once containing all the items of previous runs in a single list:
Share the output returned by the last node
Information on your n8n setup
- n8n version: 1.68.0
- Database (default: SQLite): PostgreSQL
- n8n EXECUTIONS_PROCESS setting (default: own, main): default
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
- Operating system: Linux