Hi ! Thank you for taking the time to look at this.
My workflow after your advise - did I understand something wrong ? :
If I toggle the reset option on the Inner Loop Over Items I end up in an endless loop. I only get out of this be rebooting the N8N system.
{
“nodes”: [
{
“parameters”: {},
“type”: “n8n-nodes-base.manualTrigger”,
“typeVersion”: 1,
“position”: [
-144,
-64
],
“id”: “dded6d9b-9f8d-4227-8fc5-12159d18723b”,
“name”: “When clicking ‘Execute workflow’”
},
{
“parameters”: {},
“type”: “n8n-nodes-base.wait”,
“typeVersion”: 1.1,
“position”: [
912,
-64
],
“id”: “6bcb6624-8761-4f94-879c-2dc3cfb6fe7b”,
“name”: “Wait”,
“webhookId”: “f3fe0b63-6c82-49eb-8380-d60c3f1541c6”
},
{
“parameters”: {},
“type”: “n8n-nodes-base.noOp”,
“typeVersion”: 1,
“position”: [
672,
96
],
“id”: “d7112c4a-6db2-4a14-98d1-f5c218502e8a”,
“name”: “Inner loop”
},
{
“parameters”: {},
“type”: “n8n-nodes-base.noOp”,
“typeVersion”: 1,
“position”: [
1120,
128
],
“id”: “08aed799-7b15-4f38-be6e-35f74f432366”,
“name”: “Outer loop”
},
{
“parameters”: {
“options”: {
“reset”: true
}
},
“type”: “n8n-nodes-base.splitInBatches”,
“typeVersion”: 3,
“position”: [
448,
32
],
“id”: “acf6c806-01e4-4b38-8aac-14f488408e89”,
“name”: “Inner Loop Over Items”
},
{
“parameters”: {
“batchSize”: 100,
“options”: {}
},
“type”: “n8n-nodes-base.splitInBatches”,
“typeVersion”: 3,
“position”: [
240,
-32
],
“id”: “05ed47b8-8ecc-4313-8702-e3cf2ddb1adb”,
“name”: “Outer Loop Over Items”
},
{
“parameters”: {
“jsCode”: “const items = ;\n\nfor(let i = 1; i <= 2000; i++) {\n items.push({\n json: {\n id: i,\n }\n })\n}\n\nreturn items;”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
32,
-64
],
“id”: “8af1c78b-59a6-42df-a269-2f3c36dbcc5a”,
“name”: “Create Items”
},
{
“parameters”: {
“jsCode”: “// Loop over input items and add a new field called ‘myNewField’ to the JSON of each one\nfor (const item of $input.all()) {\n item.json.myNewField = 1;\n}\n\nreturn $input.all();”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
672,
-64
],
“id”: “7676d152-fae2-4a54-94ef-4b3c685b1ed6”,
“name”: “Code in JavaScript”
}
],
“connections”: {
“When clicking ‘Execute workflow’”: {
“main”: [
[
{
“node”: “Create Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“Wait”: {
“main”: [
[
{
“node”: “Outer loop”,
“type”: “main”,
“index”: 0
}
]
]
},
“Inner loop”: {
“main”: [
[
{
“node”: “Inner Loop Over Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“Outer loop”: {
“main”: [
[
{
“node”: “Outer Loop Over Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“Inner Loop Over Items”: {
“main”: [
[
{
“node”: “Code in JavaScript”,
“type”: “main”,
“index”: 0
}
],
[
{
“node”: “Inner loop”,
“type”: “main”,
“index”: 0
}
]
]
},
“Outer Loop Over Items”: {
“main”: [
,
[
{
“node”: “Inner Loop Over Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“Create Items”: {
“main”: [
[
{
“node”: “Outer Loop Over Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“Code in JavaScript”: {
“main”: [
[
{
“node”: “Wait”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“instanceId”: “3a5f2016f235f0058559dcaa60a889f9bd210e06a6a8d1adec8c4d5747d8d207”
}
}