I think I may have found a solution:
{
"nodes": [
{
"parameters": {
"value1": "={{$json[\"type\"]}}",
"rules": {
"rules": [
{
"operation": "equal"
},
{
"operation": "equal",
"value2": 1,
"output": 1
}
]
}
},
"name": "Switch item type",
"type": "n8n-nodes-base.switch",
"typeVersion": 1,
"position": [
810,
290
],
"alwaysOutputData": true
},
{
"parameters": {
"values": {
"string": [
{
"name": "input",
"value": "input2"
},
{
"name": "additionalProperty",
"value": "bottomResolvedValue"
}
],
"boolean": [
{
"name": "dummyData"
}
]
},
"options": {}
},
"name": "Set2",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
1040,
560
]
},
{
"parameters": {
"functionCode": "let newItems = [\n {\n json: {\n pos: 0,\n type: 0\n }\n },\n {\n json: {\n pos: 1,\n type: 0\n }\n }\n]\n\nreturn newItems"
},
"name": "Emit Same Type Items",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
430,
190
]
},
{
"parameters": {
"functionCode": "let newItems = [\n {\n json: {\n pos: 0,\n type: 0\n }\n },\n {\n json: {\n pos: 1,\n type: 1\n }\n }\n]\n\nreturn newItems\n"
},
"name": "Emit Different Type Items",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
420,
480
]
},
{
"parameters": {
"functionCode": "return item"
},
"name": "FunctionItem",
"type": "n8n-nodes-base.functionItem",
"typeVersion": 1,
"position": [
610,
290
]
},
{
"parameters": {},
"name": "Merge",
"type": "n8n-nodes-base.merge",
"typeVersion": 1,
"position": [
1470,
280
]
},
{
"parameters": {
"mode": "passThrough",
"output": "={{$json[\"dummyData\"] === true ? 'input2' : 'input1' }}"
},
"name": "Merge1",
"type": "n8n-nodes-base.merge",
"typeVersion": 1,
"position": [
1320,
450
]
},
{
"parameters": {
"values": {
"boolean": [
{
"name": "dummyData",
"value": true
}
],
"string": []
},
"options": {
"dotNotation": false
}
},
"name": "Set",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
1140,
380
]
},
{
"parameters": {
"functionCode": "return items.filter(i => !i.json.dummyData)"
},
"name": "Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
1750,
280
]
}
],
"connections": {
"Switch item type": {
"main": [
null,
[
{
"node": "Set2",
"type": "main",
"index": 0
}
]
]
},
"Set2": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 1
}
]
]
},
"Emit Different Type Items": {
"main": [
[
{
"node": "FunctionItem",
"type": "main",
"index": 0
}
]
]
},
"FunctionItem": {
"main": [
[
{
"node": "Switch item type",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Function",
"type": "main",
"index": 0
}
]
]
},
"Merge1": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Set": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 0
},
{
"node": "Merge1",
"type": "main",
"index": 1
}
]
]
}
}
}
I have 2 emitting functions. one emits data that is of the same type, the other is of different types. I use the Set Node
to add a new property dummyData
with value false
to both routes. But when it travels the top route it a) sets dummyData
to true
and also triggers the bottom route via a pass-through merge. the passed through input data is evaluated based on the dummyData
property once again and if it is true it forwards-the dummy data, else it forwards the “good” data. After both branches I merge the 2 route via append and filter out all items with dummydata: true
.
Pretty cumbersome imho but it seems to do the trick.
Edit: well in my bigger scenario it does not work like that. seems to be a race condition since the resolving on the database actually takes a while but preppying the dummyData is instant. 