When I look at the "Monitor Bulk Data Load Jobs" link in my salesforce org, I see a count of batches consumed in the last 24 hours. An example is shown below.
Your organization has processed **821 batches** in the last 24 hours. Your organization can process 2,000 batches in a 24-hour period.
Is there a way to get this information by running a SOQL?
Attribution to: Balaji Pooruli
Possible Suggestion/Solution #1
From this it doesn't seem like there's a way to query for Bulk Load jobs.
You can query the AsyncApexJob table for a count of records where the type is BatchApex, which is the only seemingly log of all things Batch
Select count(Id) from asyncapexjob where JobType='BatchApex' and CreatedDate > Yesterday
However this doesn't seem to include Bulk Data Loads
Attribution to: techtrekker
Possible Suggestion/Solution #2
The snippet of code below gets the number of batches, and also the number of items in all batches:
List<AsyncApexJob> lstjobs=[
SELECT
Id,
TotalJobItems
FROM
AsyncApexJob
WHERE
CompletedDate = TODAY
AND JobType='BatchApex'];
Integer jobItemsCount = 0;
Integer batchesCount = 0;
for(AsyncApexJob async : lstjobs) {
jobItemsCount += async.TotalJobItems; //Add the no of batches processed
batchesCount++;
}
Attribution to: Mohith Shrivastava
Possible Suggestion/Solution #3
You might have to use HTTP requests to get that info. See Bulk API for more info, this link looks particularly interesting.
Attribution to: eyescream
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4298