Good day everyone,

I have created a batch process. Let say I have thousands of records to process. Now what i want is when there is an error encounter or some problem found in the data during the batch process, I want to stop or abort the batch process. Is it possible ? thank you.

1 Answer 1


I've never tried it, but I don't see anything in the System.abortJob documentation that says it doesn't work when called from the batchable so try:

public void execute(Database.BatchableContext bc, List<SObject> scope) {
    try {
    } catch (Exception e) {
        // Report errors here

I assume that making this call will also stop the finish method being called so you will have to do any error reporting immediately before the call.

  • 1
    I've tried it and i think its working . Thank you.
    – Hope
    Commented Jul 17, 2015 at 9:17

You must log in to answer this question.

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