PDI · Question #40
Universal Containers has implemented an order management application. Each Order can have one or more Order Line items. The Order Line object is related to the Order via a master-detail…
The correct answer is A. Roll-up summary field. The best practice to calculate the sum of Order Line Item totals on the parent Order record, given a master-detail relationship, is to use a Roll-Up Summary field.
Question
Universal Containers has implemented an order management application. Each Order can have one or more Order Line items. The Order Line object is related to the Order via a master-detail relationship. For each Order Line item, the total price is calculated by multiplying the Order Line item price with the quantity ordered. What is the best practice to get the sum of all Order Line item totals on the Order record?
Options
- ARoll-up summary field
- BQuick action
- CApex trigger
- DFormula field
How the community answered
(40 responses)- A75% (30)
- B15% (6)
- C8% (3)
- D3% (1)
Why each option
The best practice to calculate the sum of Order Line Item totals on the parent Order record, given a master-detail relationship, is to use a Roll-Up Summary field.
A Roll-Up Summary field is the most efficient and declarative way to calculate aggregate values, such as the sum of child record fields, and display them on the master record in a master-detail relationship.
A Quick Action provides a way to launch actions or create records but does not automatically calculate and store aggregated values on a parent record.
While an Apex trigger could achieve this calculation, it is a programmatic solution and not considered best practice when a declarative option like a Roll-Up Summary field is available for the exact use case.
A formula field can display data from related records but cannot directly aggregate values across multiple child records like summing their totals.
Concept tested: Roll-Up Summary fields for aggregation (SUM)
Source: https://help.salesforce.com/s/articleView?id=sf.fields_about_roll_up_summary_fields.htm&type=5
Topics
Community Discussion
No community discussion yet for this question.