PDI · Question #144
The Account object in an organization has a master detail relationship to a child object called Branch. The following automations exist: - Rollup summary fields - Custom validation rules - Duplicate…
The correct answer is A. Rollup summary fields can cause the parent record to go through Save. B. The trigger may fire multiple times during a transaction. When testing an Account trigger, developers must consider that rollup summary field recalculations can initiate a re-save of the parent record, and the trigger itself may execute multiple times within a single transaction due to subsequent updates.
Question
The Account object in an organization has a master detail relationship to a child object called Branch. The following automations exist:
- Rollup summary fields
- Custom validation rules
- Duplicate rules
A developer created a trigger on the Account object. What two things should the developer consider while testing the trigger code? Choose 2 answers
Options
- ARollup summary fields can cause the parent record to go through Save.
- BThe trigger may fire multiple times during a transaction.
- CDuplicate rules are executed once all DML operations commit to the database.
- DThe validation rules will cause the trigger to fire again.
How the community answered
(34 responses)- A79% (27)
- C15% (5)
- D6% (2)
Why each option
When testing an Account trigger, developers must consider that rollup summary field recalculations can initiate a re-save of the parent record, and the trigger itself may execute multiple times within a single transaction due to subsequent updates.
When child records in a master-detail relationship are created, updated, or deleted, rollup summary fields on the parent (Account) are recalculated, which can cause the parent record to undergo a save operation and potentially re-fire its triggers.
Due to Salesforce's order of execution, various automations like workflow rules or rollup summary updates can cause a record to be saved again within the same transaction, leading to the trigger firing multiple times.
Duplicate rules are executed earlier in the save order, specifically before saving the record to the database, and they do not wait until all DML operations commit.
While validation rules execute before DML, they will not directly cause the trigger to fire again; rather, a subsequent update by another automation, possibly initiated after validation, would cause the re-fire.
Concept tested: Salesforce trigger order of execution
Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm
Topics
Community Discussion
No community discussion yet for this question.