I have a trigger from which I am calling a batch class. When I insert a bulk amount of data the trigger is fired for every 200 records and the batch is getting executed. Hence multiple batches are being fired from the trigger. Is there any way where I can call the batch class only after the trigger has finished processing all the records? Like I am inserting 1400 records hence trigger is being fired for every 200 records which means the total trigger is being fired 7 times and 7 batches are being executed. Is there any way only after the last execution of the trigger i can call the batch class?

1 Answer 1


Nope, Salesforce doesn't provide us a way to know when the final chunk of records for a DML statement is being run.

If you are performing this DML yourself, explicitly in code (i.e. not through something like DataLoader), then you could call executeBatch() after the DML returns (rather than doing it in the trigger that is run because of that DML).

Failing that, you could write a small class that implements the Schedulable interface to cause your batch to run on a regular schedule (like, say, once a day). The idea being that you can just mark the records that need to be processed, and have the batch class simply pick up all of the "records to be processed".

  • if only we would get transaction finalizers for other than queueables
    – cropredy
    Jul 14, 2022 at 14:57

You must log in to answer this question.

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