3

I am developing data model like master - Order, childs - Order items. There is master-detail relationship. Order items have quantity and price per each item. How do I create read-only field on master record to calculate total amount (sum of amounts of each child multiplied by quantity) without using trigger?

6

Just create a custom field on the parent object using the rollup summary data type. The field creation wizard will walk you though it. Create a formula field on the child "Total Amount" (quantity * unit price), then sum the formula.

  • I am afraid I can't do it this way. Imagine I have one order with one order item - price 1000, quantity - 2. So I want to see total price 2000 on master record. But with rollup summary I can get count or sum, but not multiply price by quantity. – Vladyslav K Apr 12 '16 at 15:31
  • 1
    What about using two hidden custom fields, one for price and one for quantity, with a third to do the calculation? – JaredT Apr 12 '16 at 15:39
  • 3
    @VladyslavKushney Create a formula field on the child "Total Amount" (quantity * unit price), then sum the formula. – sfdcfox Apr 12 '16 at 15:46
  • @sfdcfox this worked great – Vladyslav K Apr 12 '16 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.