PDI · Question #87
A company has a custom object, Sales, }_Help_Request__c, that has a Lookup relationship to Opportunity. The Seles Help Request__c has a mumber field, Number_ct_Hours__c, that represents the amount…
The correct answer is D. A record-triggered flow on the Sales Help Request__c object. To sum the Number_of_Hours__c from child Sales_Help_Request__c records onto a parent Opportunity record through a lookup relationship, a record-triggered flow on the Sales_Help_Request__c object is the most appropriate and declarative solution.
Question
A company has a custom object, Sales, }_Help_Request__c, that has a Lookup relationship to Opportunity. The Seles Help Request__c has a mumber field, Number_ct_Hours__c, that represents the amount of time spent on the Sales_Help Request__C. A developer is tasked with creating a field, total_Hour2__c, on Opportunity that should be the sum of all of the Number_of_Hours_c values for the Sales_Help_Request__c records related to that Opportunity. What should the developer use to implement this?
Options
- AA roll-up summary field on the sales Help_Request__c object
- BA trigger on the Opportunity object
- CA roll-up summary field on the Opportunity object
- DA record-triggered flow on the Sales Help Request__c object
How the community answered
(35 responses)- A3% (1)
- B3% (1)
- C11% (4)
- D83% (29)
Why each option
To sum the `Number_of_Hours__c` from child `Sales_Help_Request__c` records onto a parent `Opportunity` record through a lookup relationship, a record-triggered flow on the `Sales_Help_Request__c` object is the most appropriate and declarative solution.
A roll-up summary field must be created on the *parent* object (`Opportunity`) to summarize child records; creating it on the child object would not achieve the desired aggregation on the `Opportunity`.
While an Apex trigger on the `Opportunity` object could achieve this, it involves more complex logic and higher maintenance compared to a declarative flow, and a trigger on the `Sales_Help_Request__c` would be more efficient for child-to-parent rollups in Apex.
A roll-up summary field on the `Opportunity` object cannot directly sum values from `Sales_Help_Request__c` records because `Sales_Help_Request__c` has a Lookup relationship to `Opportunity`, not a Master-Detail relationship, which is a prerequisite for standard roll-up summary fields.
A record-triggered flow on the `Sales_Help_Request__c` object is the most suitable declarative solution. When a `Sales_Help_Request__c` record is created, updated, or deleted, the flow can query all related `Sales_Help_Request__c` records for the parent `Opportunity`, sum their `Number_of_Hours__c` values, and then update the `total_Hours__c` field on the associated `Opportunity`.
Concept tested: Roll-up summary with Lookup relationships
Source: https://help.salesforce.com/s/articleView?id=sf.lookup_roll_up_summary_fields.htm&type=5
Topics
Community Discussion
No community discussion yet for this question.