7

Is there a way to delete an AsyncApexJob with Queued status ?

I can't do it in the Setup because I don't have any action link available for this jobs.

I can't do it with the purgeOldAsyncJobs() method because it doesn't clear jobs with this status.

And I can't do it with Developer console because after listing this jobs, if I try to delete them I got this error message :

[object Object]: insufficient access rights on object id

I'm connected as System Administrator.

Any ideas to do this ?

0
7

If it's queued that implies its scheduled, therefore you should be able to get the Job ID and abort it, e.g.

System.abortJob(jobId);
0
11

In case Phil's solution doesn't work, and you are stuck with a zombie Queued AsyncApexJob, here's a workaround:


At Version 39.0, an attempt to delete a zombie Queued AsyncApexJob that has no associated CronTrigger using

System.abortJob(theAsyncApexJobId)

fails with:

System.StringException: You can’t abort scheduled Apex jobs by calling System.abortJob with an AsyncApexJob ID. Call System.abortJob with the parent CronTrigger ID

But, if you go into Workbench and downgrade to Version 31.0 (other versions may work as well)

and execute

System.abortJob(theAsyncApexJobId)

It works! and the AsyncApexJob's status is switched to Aborted.

This is a huge plus especially for developers without Premier Support who otherwise might not get any SFDC assistance on this issue in a sandbox or DE.

1
  • @PhilHawthorn - I tried your solution (v39), which killed the CronTrigger but left the AsyncApexJob as a zombie. Not sure why.
    – cropredy
    May 6 '17 at 1:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.