As Per Salesforce
Governor Limits, Total stack depth for any Apex invocation that recursively
fires triggers due to insert, update, or delete statements size is 16. If you go beyond this limit you will get “Maximum
Trigger Depth Exceeded error”.
The below code is one
of the example of getting this error,
- trigger DuplicateRecordMaker on Account (after insert, after update)
- {
- List<Account> accounts = new List<Account>();
- for(Account currentAccount : Trigger.New)
- {
- Account acc = new Account();
- acc.Name = currentAccount.Name;
- accounts.add(acc);
- }
- insert accounts;
- }
Reason for getting such error,
My
Trigger concept is whenever account record is created, the same record should
be created as duplicate record. After insert a record the above trigger will fire
then duplicate record will process after that trigger will call recursively, this
cause a Maximum Trigger Depth Exceeded error.
No comments:
Post a Comment