AutomationFlowsGeneral › Split Data in Batches with Current Run Index

Split Data in Batches with Current Run Index

Original n8n title: Split in Batches Node Currentrunindex Example

Split In Batches Node Currentrunindex Example. Uses manualTrigger, splitInBatches. Event-driven trigger; 5 nodes.

Event trigger★★★★☆ complexity5 nodes
General Trigger: Event Nodes: 5 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "name": "On clicking 'execute'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        430,
        310
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "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
    },
    {
      "name": "SplitInBatches",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        830,
        310
      ],
      "parameters": {
        "options": {},
        "batchSize": 1
      },
      "typeVersion": 1
    },
    {
      "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
    },
    {
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "position": [
        1230,
        360
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "Message",
              "value": "Loop Ended"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 1
    }
  ],
  "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
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Split In Batches Node Currentrunindex Example. Uses manualTrigger, splitInBatches. Event-driven trigger; 5 nodes.

Source: https://github.com/Zie619/n8n-workflows — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

Product - Google Search Console API Examples. Uses httpRequest. Event-driven trigger; 36 nodes.

HTTP Request
General

Metavoir Creative Intake To Review Brief. Event-driven trigger; 21 nodes.

General

Retry on fail except for known error Template. Uses stopAndError, noOp, stickyNote, manualTrigger. Event-driven trigger; 19 nodes.

Stop And Error
General

Retry on fail except for known error Template. Uses stopAndError. Event-driven trigger; 19 nodes.

Stop And Error
General

02 - Flow Control Demo (IF & Switch). Event-driven trigger; 16 nodes.