I have written before update trigger on an object. In that trigger I am invoking batch Apex to update the same object records but in apexjob am getting error like this

First error: Update failed. First exception on row 0 with id a0A9000000V5kLGEAZ; >First error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CandidateUpdate: execution of AfterUpdate caused by: System.AsyncException: Database.executeBatch cannot be called from...

What should I do to avoid this error?

  • Can you include the code that you are having difficulties with?
    – Joseph U.
    Commented Mar 30, 2015 at 0:21

2 Answers 2


You can't perform an update from a before trigger or call anything that invokes an update. You need make your trigger an After Update.


Move the batch call to after insert.

You will have to write some logic to avoid recursive updates on record. Trigger updates record -> batch updates record in same object -> again trigger fires and it loops till hitting limit.

Also be careful while calling batch class from trigger. If same batch is in queue more than 5 times, code will fail with "Maximum concurrent batches exceeded" exception. So if five users are updating records at the same time, you may hit this limit.

You must log in to answer this question.

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