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


No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit