n8n Workflow

Split In Batches Node Currentrunindex Example

This n8n workflow automates tasks and integrates with various services. Split In Batches Node Currentrunindex Example - ready to import and run in your n8n instance.

n8n workflow.json

About This Script

This n8n workflow automates tasks and integrates with various services. Split In Batches Node Currentrunindex Example - ready to import and run in your n8n instance.
Features:
  • Custom JavaScript function processing
  • Conditional logic and branching
Source Code
{
    "nodes": [
        {
            "name": "On clicking 'execute'",
            "type": "n8n-nodes-base.manualTrigger",
            "position": [
                430,
                310
            ],
            "parameters": [],
            "typeVersion": 1,
            "id": "9b49a9f4-1649-4b85-a9af-5262c21273e4"
        },
        {
            "name": "Function",
            "type": "n8n-nodes-base.function",
            "position": [
                630,
                310
            ],
            "parameters": {
                "functionCode": "const newItems = [];\n\nfor (let i=0;i<10;i++) {\n  newItems.push({json:{i}});\n}\n\nreturn newItems;"
            },
            "typeVersion": 1,
            "id": "d9a2c72f-a0b3-44d6-90e4-bc79fc097b94"
        },
        {
            "name": "SplitInBatches",
            "type": "n8n-nodes-base.splitInBatches",
            "position": [
                830,
                310
            ],
            "parameters": {
                "options": [],
                "batchSize": 1
            },
            "typeVersion": 1,
            "id": "82dfca00-a4aa-4d9a-b7ca-e674d76cdcb7"
        },
        {
            "name": "IF",
            "type": "n8n-nodes-base.if",
            "position": [
                1030,
                460
            ],
            "parameters": {
                "conditions": {
                    "number": [
                        {
                            "value1": "={{$node[\"SplitInBatches\"].context[\"currentRunIndex\"];}}",
                            "value2": 5,
                            "operation": "equal"
                        }
                    ],
                    "boolean": []
                }
            },
            "typeVersion": 1,
            "id": "c93714b4-8271-4797-b974-537ed1505588"
        },
        {
            "name": "Set",
            "type": "n8n-nodes-base.set",
            "position": [
                1230,
                360
            ],
            "parameters": {
                "values": {
                    "string": [
                        {
                            "name": "Message",
                            "value": "Loop Ended"
                        }
                    ]
                },
                "options": [],
                "keepOnlySet": true
            },
            "typeVersion": 1,
            "id": "6c6364dc-7d53-446b-bfa4-aefff50b28ce"
        }
    ],
    "connections": {
        "IF": {
            "main": [
                [
                    {
                        "node": "Set",
                        "type": "main",
                        "index": 0
                    }
                ],
                [
                    {
                        "node": "SplitInBatches",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Function": {
            "main": [
                [
                    {
                        "node": "SplitInBatches",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "SplitInBatches": {
            "main": [
                [
                    {
                        "node": "IF",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "On clicking 'execute'": {
            "main": [
                [
                    {
                        "node": "Function",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        }
    },
    "n8n_version": "1.5.0"
}
Requirements
n8n instance, API credentials for connected services
Tags
#n8n #automation #workflow
Quick Actions
More in n8n Workflows