PDI · Question #57
PDI Question #57: Real Exam Question with Answer & Explanation
The correct answer is A: Implement the line amount as a numeric formula field and the order amount as a roll-up summary. The line item amount should be a formula field calculating Quantity * Price, while the order amount should be a roll-up summary field on the Order object summing the line item amounts from its master-detail child records.
Question
An org tracks customer orders on an Order object and the items of an Order on the Line Item object. The Line Item object has a MasterDetail relationship to the order object. A developer has a requirement to calculate the order amount on an Order and the line amount on each Line item based on quantity and price. What is the correct implementation?
Options
- AImplement the line amount as a numeric formula field and the order amount as a roll-up summary
- BWrite a single before trigger on the Line Item that calculates the item amount and updates the
- CImplement the Line amount as a currency field and the order amount as a SUM formula field.
- DWrite a process on the Line item that calculates the item amount and order amount and updates
Explanation
The line item amount should be a formula field calculating Quantity * Price, while the order amount should be a roll-up summary field on the Order object summing the line item amounts from its master-detail child records.
Common mistakes.
- B. While a trigger could achieve this, declarative solutions (formula and roll-up summary fields) are preferred when available for lower maintenance and faster development, especially for straightforward calculations.
- C. A "SUM formula field" is not a standard declarative field type in Salesforce; roll-up summary fields are used for aggregation across related records in master-detail relationships.
- D. A Process Builder could potentially update fields, but it would be less efficient and higher maintenance than a formula field for the line amount and a roll-up summary for the order amount, both of which are declarative and automatically handled.
Concept tested. Formula and Roll-Up Summary fields
Reference. https://help.salesforce.com/s/articleView?id=sf.fields_about_formula_fields.htm&type=5
Topics
Community Discussion
No community discussion yet for this question.