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
MiddhaMiddha 

Trigger Context: Workaround for 100 DML statement limit in a trigger

Hi,

I have a requirement where i need to issue more then 100 DML statements in a trigger. But as per the trigger governor limits only 100 DML statements are allowed.

I also tried calling the trigger recursively, i.e. issuing 90 DML statements in a trigger and updating the record again, so that the trigger executes again on that record issuing another 90 DML statements until the processing completes.

But i noticed that calling the trigger recursively uses the same context and the DML statements keeps on adding to the same context.

Is there any other workaround for this where i can process more then 100 records.

GreatG
Best Answer chosen by Admin (Salesforce Developers) 
Shadow8002Shadow8002
There is currently no ready-made easy solution for this. You could try to do this using Visual Force pages where you split up the API calls so that the number of items processed is always less than 100.

SalesForce will also be coming out with batch apex where you can run them on a schedule. These classes will not have any governor limits associated.


All Answers

jpizzalajpizzala
Instead of issuing a DML call for each record you need to process, why don't you put all of your records to be processed into a collection and then execute 1 DML statement on that collection?
MiddhaMiddha
My Bad, actually its not DML statements, 100 is the number of records that are processed with the DML statements. I am issuing only 3 (bulk) DML statements which have more then 100 records.
Shadow8002Shadow8002
There is currently no ready-made easy solution for this. You could try to do this using Visual Force pages where you split up the API calls so that the number of items processed is always less than 100.

SalesForce will also be coming out with batch apex where you can run them on a schedule. These classes will not have any governor limits associated.


This was selected as the best answer