Adding two decimal numbers

varunkumar1
Tera Contributor

Hi,

I have three decimal fields A, B and C on a form. I have given some decimal values on A and B fields. On submitting this record.

I want to add these two values and set it on C field.

Please let me know how can we do this.

Thanks

2 REPLIES 2

Harish KM
Kilo Patron
Kilo Patron

Here is an example:



(function executeRule(current, previous /*null when async*/) {




var number_1 =   parseFloat(current.u_num1);// field A


var number_2 =   parseFloat(current.u_num2);// field B


var number_3 = parseFloat(number_1) + parseFloat(number_2); //A+B


  current.u_num3 = number_3;//set to C





})(current, previous);



find_real_file.png



find_real_file.png



Ouptut:


find_real_file.png


Regards
Harish

sunilsafare
Mega Guru

Hi Dhileep,



Use before update business rule to store the value in C column. If you have declared the A and B columns as string fields then convert it as float and store in C as below



var a = current.A;


var b = current.B;



current.C = parseFloat(a)+parseFloat(b);



Thanks,


Sunil Safare