AnsweredAssumed Answered

SugarCrm 7.9: Quote Line Items Formula [related()] not working onChange

Question asked by Aravind Kumar on Feb 26, 2018
Latest reply on Feb 26, 2018 by Offshore Evolution

I have a field in Product module (Quote Line Items), the field has formula to calculate when there is a value in other fields. 

 

When i test in Product module its working fine. But when i use the field in Quote Line item its not working only on Saving the particular line item it is reflecting. Do we need to add anything additionally in quote-data-group-list.php

 

My Field:

$dictionary['Product']['fields']['revenue_c'] = array(
    'audited' => true,
    'calculated' => true,
    'formula' => '
        ifElse(
            greaterThan($list_price, 0),
            subtract(
                multiply($list_price, $quantity),
                $discount_amount
            ),
            multiply($product_cost_c, $quantity)
        )',
    'name' => 'revenue_c',
    'readonly' => true,
    'reportable' => true,
    'enforced' => true,
    'required' => false,
    'source' => 'custom_fields',
    'type' => 'currency',
    'vname' => 'LBL_REVENUE',
);

IMPORTANT: 

$product_cost_c

is a calculation field which has related() field from other module.

 

In My quote-data-group-list.php

array(
    'name' => 'revenue_c',
    'label' => 'LBL_REVENUE',
    'type' => 'currency',
    'convertToBase' => true,
    'showTransactionalAmount' => true,
    'related_fields' => array(
        'revenue_c',
        'currency_id',
        'base_rate',
    ),
),

Questions: What additional configuration we need to use to make the formula work in Quote Line Items Onchange?

 

 

If you see the above image the value is calculated only after saving the line item, But in Product module we can able to get value before saving the product, So in order to make the formula work as like in product module, What config changes we need to do in quote-data-group-list.php

Outcomes