Call calculateTotal() function on studio added fields

Hi,

I have added three additional fields on quotes using studio

1)Additional discount
2)Promotional discount
3)Agent discount

i want to call the javascript calculateTotal(‘lineItems’); on these fields,so that my grand total field shows the updated value.I have searched the line_items.php page but couldn’t find the fields there.How can i call this?

Can any one help me please…

take a look at this post on how to use javascript https://suitecrm.com/forum/suitecrm-7-0-discussion/11050-display-subpanel-based-on-field#37723

best regards

1 Like

You can call the calculateTotal(‘line_items’) on a custom field in custom/modules/AOS_Quotes/metadata/editviewdefs.php by adding an onblur event. For example for tax_amount you’ll see the following:

name' => 'tax_amount',
            'label' => 'LBL_TAX_AMOUNT',
            'displayParams' => 
            array (
              'field' => 
              array (
                'onblur' => 'calculateTotal(\'lineItems\');',
              ),
            ),
1 Like

On custom/modules/AOS_Quotes/metadata/editviewdefs.php I have called calculateTotal() on multiple fields ,It 's working for the first field but has no effect on other fields.array is like the following.

5 =>
array (
0 =>
array (
‘name’ => ‘additional_discount_c’,
‘label’ => ‘LBL_ADDITIONAL_DISCOUNT’,
‘displayParams’ =>
array (
‘field’ =>
array (
‘onblur’ => ‘calculateTotal(‘lineItems’);’,
),
),
),
),
6 =>
array (
0 =>
array (
‘name’ => ‘agent_discount_c’,
‘label’ => ‘LBL_AGENT_DISCOUNT’,
‘displayParams’ =>
array (
‘field’ =>
array (
‘onblur’ => ‘calculateTotal(‘lineItems’);’,
),
),
),
),

additional discount field recalculate the total on onblur event,but agent discount field no effect on totals when updated.
How can i make the calculation work on agent discount field as well?.Please guide me on this.

Thanks

sorry, my mistake.Forgot to update the fields on line_items.js