function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ryanhcaryanhca 

Getting the number of queued batch jobs

We're only allowed to have 5 jobs in the queue for batch processing at a time. Ordinarily there's a method on the Limits class that allows us to get to info regarding limits, etc but I can't find one in this case. My money's on a bug in the documentation... Any help?

 

Current documentation: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_limits.htm

Best Answer chosen by Admin (Salesforce Developers) 
sforce2009sforce2009

There is an object calles ApexAsyncJob. All the processing jobs will be there as records. You can query and check whether there are already jobs in queue using Status field of that object.

All Answers

sforce2009sforce2009

There is an object calles ApexAsyncJob. All the processing jobs will be there as records. You can query and check whether there are already jobs in queue using Status field of that object.

This was selected as the best answer
jkucerajkucera

Thanks sforce2009!  

 

Any idea how to "wait" to add a job once the queue is open?  I'm thinking something like saving the settings in a custom object, and having a scheduled apex job check the queue for openings, and add the custom object settings back into the batch method to queue up another batch job.