System.LimitException: Too many DML statements: meaning and how to fix it
Quick answer
System.LimitException: Too many DML statements: A transaction ran more DML statements than the governor limit, usually a DML call inside a loop. Start with: Add records to a list inside the loop and run one DML statement afterwards.
Typical message: System.LimitException: Too many DML statements: 151
Cause
A transaction ran more DML statements than the governor limit, usually a DML call inside a loop.
How to fix System.LimitException: Too many DML statements
- Add records to a list inside the loop and run one DML statement afterwards.
- Check that triggers, flows and process automation on the same object are not each doing their own updates.
Have a different message? Paste it into the error decoder, which matches it against 45 common Salesforce errors in your browser.
Frequently asked questions
What does System.LimitException: Too many DML statements mean in Salesforce?
A transaction ran more DML statements than the governor limit, usually a DML call inside a loop.
How do I fix System.LimitException: Too many DML statements?
1. Add records to a list inside the loop and run one DML statement afterwards. 2. Check that triggers, flows and process automation on the same object are not each doing their own updates.
More Governor limits errors
SFDX Talk is unofficial documentation. It is not affiliated with, endorsed by, or sponsored by Salesforce, Inc. Message text varies slightly by release and context, so confirm against the official page before relying on it.