PDI · Question #217
A developer created a trigger on the Account object. While testing the trigger, the developer sees the error message 'Maximum trigger depth exceeded'. What could be the possible causes?
The correct answer is B. The trigger is getting executed multiple times. The 'Maximum trigger depth exceeded' error typically indicates that a trigger is recursively calling itself or other triggers, leading to an excessive number of executions within a single transaction.
Question
A developer created a trigger on the Account object. While testing the trigger, the developer sees the error message 'Maximum trigger depth exceeded'. What could be the possible causes?
Options
- AThe developer does not have the correct user permission.
- BThe trigger is getting executed multiple times.
- CThe trigger is a a helper class.
- DThe trigger does not have sufficient code coverage.
How the community answered
(49 responses)- B94% (46)
- C2% (1)
- D4% (2)
Why each option
The 'Maximum trigger depth exceeded' error typically indicates that a trigger is recursively calling itself or other triggers, leading to an excessive number of executions within a single transaction.
User permissions control what data a user can access or actions they can perform, but they do not directly cause a 'Maximum trigger depth exceeded' error related to trigger recursion.
A 'Maximum trigger depth exceeded' error occurs when a trigger causes a change that, in turn, fires the same or another trigger too many times within the same transaction context, creating an infinite loop or exceeding the recursion limit (often 16 in Salesforce).
Whether a trigger uses a helper class or not is a code organization pattern; it does not inherently cause a 'Maximum trigger depth exceeded' error, although a helper class could contain logic that leads to recursion.
Insufficient code coverage is a metric for test quality and deployment readiness, not an error that occurs during trigger execution itself; it would prevent deployment but not cause a runtime execution error like trigger depth.
Concept tested: Trigger recursion and governor limits
Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_recursion.htm
Topics
Community Discussion
No community discussion yet for this question.