0

I've just learned that finish() is never called when a batch job is aborted manually by a user from the Apex Jobs monitor. However, I would like to be able to run some logic in a batch class when its batch job is aborted manually. Is there any way to accomplish this? At the moment I can only think of either using a trigger on AsyncApexJob or firing platform events from the batch class but I am not sure if either of these will work. Any ideas?

1 Answer 1

0

AsyncApexJob does not support triggers. You might be able to use a FOR UPDATE query to obtain a lock on your current job entry to see if it's been aborted, but this is, at best, going to be a race condition. There is no reliable method to determine a hard abort when the job is cancelled from within the job.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .