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
CarlBCarlB 

Handling an aborted batch

Hello.

I have a batch process which does some clean up in the finish(...) method.  However, if the user aborts the job (e.g. they go to the list of Apex jobs and click "Abort"), this code is not executed.

I was wondering if there was any way to handle the abort event so that my clean up code is still called?

Thanks,

Carl
 
pconpcon
No, you would have to do something like write a scheduled job that looks for Aborted jobs and then run your code.  Alternatively you could make your clean up code a static class level method somewhere and call that manually when you abort.