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
nickname142857nickname142857 

ScheduledJobs

Anyone knows where (which object) are they stored? Or are there system methods I can use to get a list of them? I need to delete ones that are obsolete in Apex code.

tmatthiesentmatthiesen

the entity is crontrigger: 

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_scheduler.htm?SearchType=Stem


To abort jobs you can use: System.abortJob(String CronTriggerID);

nickname142857nickname142857

I need to either change the schedule or delete altogether (so I can create a new one) in the Apex code. I played with the CronTrigger object, but neither seems possible because it does not allow me to delete records in CronTrigger or to change NextFireTime.

 

tmatthiesentmatthiesen

You can't perform DML directly on crontrigger.  Please look at the documentation for creating or aborting jobs programmatically.