Adding two decimal numbers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2017 11:46 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2017 11:55 PM
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);
Ouptut:
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2017 11:55 PM
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