Salesforce – How to list all scheduled jobs in Apex?

Winter ’14 introduced the ability to receive name and type in Apex and SOQL queries.

Use CronJobDetail relationship to get the job’s name and type.

SELECT Id, CronJobDetail.Id, CronJobDetail.Name, CronJobDetail.JobType FROM CronTrigger ORDER BY CreatedDate ASC LIMIT 10

You can also query CronJobDetail directly to get the job’s name and type.

SELECT Id, Name, JobType FROM CronJobDetail WHERE Id = 'someId'

To get total count of all Apex scheduled jobs (except other scheduled job types), run the following query.

SELECT COUNT() FROM CronTrigger WHERE CronJobDetail.JobType = '7'

These are available job types on the CronJobDetail SOAP API object.

  • Data Export (0)
  • Dashboard Refresh (3)
  • Analytic Snapshot (4)
  • Scheduled Apex (7)
  • Report Run (8)
  • Batch Job (9)

More information about CronJobDetail and CronTrigger

Leave a Reply

Your email address will not be published. Required fields are marked *