Salesforce Platform Developer I (legacy) — Question 45
An org tracks customer orders on an Order object and the line items of an Order on the Line Item object. The Line Item object has a Master/Detail 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?
Answer options
- A. Write a single before trigger on the Line Item that calculates the item amount and updates the order amount on the Order.
- B. Write a process on the Line Item that calculates the item amount and order amount and updates the fields on the Line Item and the Order.
- C. Implement the line amount as a numeric formula field and the order amount as a roll-up summary field.
- D. Implement the line amount as a currency field and the order amount as a SUM formula field.
Correct answer: C
Explanation
The correct answer is C because using a numeric formula field for the line amount allows real-time calculation based on quantity and price, while a roll-up summary field efficiently aggregates the line items' amounts to calculate the order total. The other options, while potentially functional, do not leverage Salesforce's features as effectively for this specific requirement.