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

593 views8 comments

Recent Posts

See All

Espocrm formula: upper case first

Here is a simple formula script helped me and I like to share with readers: // ex: name = hello world. // $firstLetterUpper = H $firstLetterUpper = string\upperCase(string\substring(name, 0, 1)); nam

bottom of page