Skip to main content

Batch Length

Uncontrolled node

Overview

The Batch Length node returns the total number of items in the current batch operation. This is useful when processing data in batches (for example, when iterating through database records in chunks) and you need to know the total size of the dataset being processed.

When running in the workflow editor (test mode), this node returns a default value of 1. During actual batch execution, it retrieves the total batch size from the workflow's batch configuration.

Inputs

This node has no inputs.

Outputs

OutputTypeDescription
lengthNumberThe total number of items in the batch. Returns 0 if no batch data is available, or 1 when running in the editor.

Runtime Behavior

When the workflow runs in batch mode, the node accesses the batchOpts configuration from the root workflow to determine the total batch size. Specifically, it reads the batchLength property from the batch options.

  • In Editor Mode: Returns 1 to provide a valid test value during workflow development
  • In Production: Returns the actual batchLength value from the batch configuration, or 0 if batch options are not configured

Example Usage

Basic Batch Processing

Connect Batch Length to other batch nodes to access the total size of your dataset:

[Batch Data] → [Your Processing Logic] → [Batch Length]

Calculating Progress

Use Batch Length with Batch Index to calculate processing progress:

[Batch Index] → [Formula: (index / length) * 100] → [Progress Percentage]
[Batch Length] ↗

Conditional Logic Based on Batch Size

Use the length output to conditionally execute logic based on the size of your batch:

[Batch Length] → [Compare: length > 100] → [If True: Send Notification]

This is particularly useful when you want to send notifications or perform additional actions only when processing large batches of data.