How to find number of pending batch jobs in Salesforce?

Sample Code:

List<String> batchStatuses = new List<String> {'Holding', 'Queued', 'Preparing', 'Processing'};
List<AsyncApexJob> listPendingJobs = [SELECT Id FROM AsyncApexJob WHERE Status IN: batchStatuses];

listPendingJobs.size() gives the number of pending batch jobs in Salesforce

Cheers!!!

No comments:

Post a Comment