Hi everyone
How should I use Merge node if first input comes from SplitInBatches loop? I want to merge each batch of 10 elements with 10 elements coming to “Input 2” (“Merge by index”, “Left join”) but execution stops after first run. I guess it’s expected behaviour but I can’t get my head around correct solution for my case. Do you have any ideas? Thanks in advance
Welcome to the community @nikitalpopov
I do not think you need the SplitBatches node there. The node will automatically do the iterations for you. Did you try without the split batches node?
To answer your question, you might want to use the multiplex operation of the Merge node. Check the example below:
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
-4120,
-120
]
},
{
"parameters": {
"mode": "multiplex"
},
"name": "Merge",
"type": "n8n-nodes-base.merge",
"typeVersion": 1,
"position": [
-3440,
-160
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "lastname",
"value": "espinoza"
}
]
},
"options": {}
},
"name": "Set",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
-3810,
-40
]
},
{
"parameters": {
"functionCode": "return [\n {\n json: {\n name: 'ricardo',\n }\n },\n {\n json: {\n name: 'ricardo',\n }\n }\n]"
},
"name": "Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
-3800,
-310
]
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Function",
"type": "main",
"index": 0
},
{
"node": "Set",
"type": "main",
"index": 0
}
]
]
},
"Set": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Function": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
}
}
}