Templates / Split in batches node currentRunIndex example

Split in batches node currentRunIndex example

Needs changes

by Harshil Agrawal ✓ · 3,209 views · created 2021-03-19 · Miscellaneous

Needs changes. This template uses 1 thing(s) that n8n 3.0 removes: Function (legacy). 1 breaking item(s) found. Static check, last run 2026-10-19.

What this workflow does

This workflow has 5 nodes and runs manually, when you click “Execute workflow”. It uses only n8n's built-in nodes.

How it runs

Trigger: Manually, when you click “Execute workflow”.

  1. Function: runs custom JavaScript (legacy Function node)
  2. SplitInBatches (Loop Over Items (Split in Batches)): loops over the items in batches
  3. If: checks a condition and branches into true / false
  4. Set (Edit Fields (Set)): sets or maps fields

Before you upgrade to n8n 3.0

1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:

  • Function (legacy) in Function: replace with Code node, mode 'Run Once for All Items'.

Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).

Removed in 3.0Replace with
Function (legacy)
Function
Code node, mode 'Run Once for All Items'

Nodes used (5)

From the author

This workflow demonstrates how to use currentRunIndex to get the running index. Function node: This node generates mock data for the workflow. Replace it with the node whose data you want to split into batches. SplitInBatches node: This node splits the data…

Excerpt from Harshil Agrawal's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.