What This Workflow Does
This workflow demonstrates how to effectively use the currentRunIndex property when processing data in batches with n8n. Batch processing is essential when dealing with large datasets that need to be divided into smaller, more manageable chunks for efficient processing.
The template provides a practical implementation showing how to track which batch is currently being processed, enabling better progress monitoring, conditional logic based on batch position, and more robust error handling for large-scale automation tasks.
How It Works
1. Data Generation
The workflow begins with a Function node that generates mock data for demonstration purposes. This simulates the kind of dataset you might be processing in a real business scenario.
2. Batch Splitting
The Split in Batches node then divides this data into smaller chunks based on your configured batch size. This prevents memory issues and timeout errors common with large dataset processing.
3. Current Batch Tracking
The workflow demonstrates how to access and utilize the currentRunIndex property, which indicates which batch number is currently being processed. This value increments with each batch execution.
4. Conditional Processing
You'll see examples of how to implement different logic for different batches based on their position in the sequence, enabling more sophisticated batch processing scenarios.
Who This Is For
This template is ideal for developers and automation specialists working with:
- Large datasets that require batch processing
- Periodic data synchronization tasks
- Bulk operations like email campaigns or CRM updates
- Processes needing progress tracking and reporting
What You'll Need
- An n8n instance (self-hosted or cloud)
- Basic understanding of n8n workflows
- A dataset or process that benefits from batch processing
- Optional: Integration with external systems for real-world implementation
Quick Setup Guide
- Download the template file
- Import into your n8n instance
- Review the Function node mock data structure
- Configure the Split in Batches node settings
- Test with your own data source
Key Benefits
Improved reliability: Batch processing prevents system overloads and timeout errors when handling large datasets, making your automations more reliable.
Better visibility: Tracking the currentRunIndex gives you clear insight into your batch processing progress for monitoring and reporting.
Flexible logic: Implement different processing rules for different batch positions based on your specific business requirements.
Performance optimization: Find the ideal batch size for your specific use case to balance processing speed and system resource usage.