Many clients asked me this question:
How can I calculate the total quantity from child entity’s quantity field
I am going to write the formula based on this structure:
This is the formula:
// Calculate the line "Total Price"
totalPrice = quantity * unitPrice;
// Calculate the parent order "Total Price"
ifThen(
entity\isAttributeChanged('totalPrice'),
$priceDiff= totalPrice - entity\attributeFetched('totalPrice');
record\update(
'Order', orderId,
'totalPrice', order.totalPrice + $priceDiff
);
);
Tell me in comments if this was helpful or if any question or suggesion