populate sum of 4 number fiels in other field dynamically

dixitreddy
Tera Contributor

Hi,

i have a requirement that in the for there r 4 fields A,B,C,D currency fields or number fiels when i enter this values in the form it should do sum of all these a+b+c+d and populate in other field called E before saving form it self it should calculate and populate

9 REPLIES 9

Community Alums
Not applicable

Hi @dixitreddy ,

Please refer below script.

For Before Business Rule 

 

var fieldA = current.getValue('field_a');
var fieldB = current.getValue('field_b');
var fieldC = current.getValue('field_c');
var fieldD = current.getValue('field_d');

var e = fieldA + fieldB+ fieldC + fieldD;
current.setValue('fieldE', e);

 

For Client Script

 

var fieldA = g_form.getValue('field_a');
var fieldB = g_form.getValue('field_b');
var fieldC = g_form.getValue('field_c');
var fieldD = g_form.getValue('field_d');

var e = fieldA + fieldB+ fieldC + fieldD;
g_form.setValue('fieldE', e);

 

 

Please mark my answer correct and helpful if this work for you

Thanks and Regards 

Sarthak

 

using client script we cant add more than two values!

script u mentiond for business rule works without saving form(sum of values will reflect without saving)?

Community Alums
Not applicable

Hi @dixitreddy ,

1. You can do like add two valeus and store the sum in seprate variable and than do that for another variable 

2. using business rule you have to save the form after that it reflect to the sun in field E

 

i need the sum before saving form