Activity Forums Salesforce® Discussions How to abort queued Apex jobs in Salesforce?

  • Anuj

    Member
    September 29, 2020 at 12:53 pm

    So you scheduled it, now you want to abort the job for some reason. How can you do? The jobs we schedule will be available in the crontrigger object. Lets query the trigger and see how we can retrieve the particular job to abort it.SELECT CreatedById, CreatedDate, CronExpression, CronJobDetailId, EndTime,Id, LastModifiedById, NextFireTime, OwnerId, PreviousFireTime, StartTime, State, TimesTriggered FROM CronTriggerSo from the above query, I found my job based on the cronexpression and createddate. I want to abort that job. So I get the id of the job and assign it to the soql query.
    CronTrigger ct = [SELECT Id FROM CronTrigger where Id=''];System.abortJob(ct.Id);

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos