How to delete AsyncApexJob with Queued status
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.
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);