Search code examples
salesforceapex-codejobsfuture

Salesforce How to cancel queued Apex Future Jobs


The organization that I am working for has a trigger on case that calls some code in a class called Cases.cls. I modified the code, but in trying to deploy I keep getting an error: pending batch or future calls.

I found 17 future jobs that are queued - since 2010!! There was one that had the text 'abort' next to it, and I was able to do so, but I don't see any way to cancel the rest of them.

I tried retrieving one of the jobs via the developer console, and was successful, but it did not allow any dml statements.

Does anyone have any idea how I can remove the queued jobs so that I can deploy my changes?


Solution

  • Rather than attempting to delete the job record via DML, have you tried using the System.abortJob(String job_Id) method from the developer console? (Link to Documentation)

    If that won't work, I would suggest contacting SFDC support, as that's most likely an internal issue on their side (our future jobs typically run within seconds of being called, so I can't imagine the circumstances that would cause a job to remain pending after two years...)