Loading

Salesforce Platform: Apex Batch Job Item Count Discrepancy

Data pubblicazione: Sep 23, 2026
Descrizione

Batch Apex is a Salesforce feature that allows processing large volumes of records in the background by dividing them into smaller chunks called batches. Each batch processes a limited number of records (typically up to 200), which helps avoid governor limits and improves performance for large data operations.

TotalJobItems (total number of batches to process) represents the total number of batches that a Batch Apex job will process. It is calculated based on the total number of records divided by the batch size.

JobItemsProcessed (number of batches completed) indicates how many batches have been processed so far in a Batch Apex job. It helps track the progress of the job as it executes.

Symptoms

When a Batch Apex job fails due to an internal Salesforce exception, the Batch Apex framework retries the operation a limited number of times before aborting the whole job upon repeated failures. Because of this, only some batches get processed while others remain unprocessed, and the batch job is not marked as aborted, either in the UI or the backend.

In some cases, AsyncApexJob data from Workbench or Developer Console may show the job as Completed with no errors or failures, yet have a TotalJobItems number greater than JobItemsProcessed.

In this case, on the Monitoring | Apex Jobs page, the Total Batches and Batches Processed columns will show equal values (equal to the number of batches that got processed, which is less than the total number of batches). Even completed jobs may show this count mismatch.

You may also see a discrepancy between the UI and the backend for Total Batches/Batches Processed values (that is, TotalJobItems/JobItemsProcessed in AsyncApexJob data from Workbench/Developer Console).

Note: This scenario is seen as a very intermittent issue.

Risoluzione

This section explains what to check when a completed Batch Apex job shows TotalJobItems greater than JobItemsProcessed.

Checking for Errors

Customers should fix the error code they received while the batch job was running to avoid discrepancies. To understand more about the errors, they can implement Batch error events for specific errors.

Checking for Unprocessed Records

If there are no errors during batch execution, use the start method query logic to check for any unprocessed records upon completion of the batch job. If you find unprocessed records that were created before batch execution and continue to appear, create a support ticket. Include the JobId and simple reproduction steps with a few records so that R&D can properly investigate.

Risorse aggiuntive

For additional help with Apex batch jobs see Salesforce Help! 

Numero articolo Knowledge

002113866

 
Caricamento
Salesforce Help | Article