EspoCRM Total quantity field calculation
top of page

Total quantity field calculation

Updated: Dec 14, 2021

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

631 views8 comments
bottom of page