Currency value not displaying 8 digit total sum

Harshada3
Tera Expert

I am displaying total of multiple values in one currency field. But when sum is 8 digits it's showing something like 6.072 When the actual total of values is 60,701,831

Attaching a screenshot for reference

Harshada3_0-1674560211773.png

Could someone please explain this behavior? Does the currency field has some restrictions?

Thank you!

 

1 ACCEPTED SOLUTION

Harshada3
Tera Expert

Hello All,

 

I found the issue in my script and I have fixed it now. I am adding a solution here for everyone.

The script includes return value was in Hexadecimal value and hence it is set incorrectly causing the issue.

I changed line no.15

from: return total;

to: return total.toFixed(2);

 

After making the above change in script includes, issue seems to be resolved.

Also, it is a best practice to use "currency code" also while setting values to currency fields using client scripts.
Example:
var currency_code = 'INR';
g_form.setValue('fieldname ',currency_code + ';'+ response);

 

I have given my scripts below. I hope this helps someone looking for the same fix as I was.

Thanks!

 

Regards,

Harshada

View solution in original post

11 REPLIES 11

shivangi k
Kilo Sage

Hi @Harshada3 

 

Could please share the BR you are using and the numbers you are adding in this particular record?

 

Regards,

Hello @shivangi k ,

 

I am setting the value from onchange client script from which I'm calling a script include. Below is the script for the calculations :

Harshada3_0-1675143185718.png

 

Regards,

Harshada

Hello @shivangi k ,

 

I'm using client script to set the value and from which I'm calling a script include. Calculations are done in script include. Please find the snap for reference : 

Harshada3_0-1675143344339.png

 

Harshada3_0-1675143407630.png

 

calculateTotal: function() {
var orderRef = this.getParameter('sysparm_order'); //'Order Reference'.
var gr = new GlideRecord("u_customer_order_booking");
gr.addQuery("u_order_management.sys_id", orderRef);
gr.query();
var total = 0;
while (gr.next()) {
var basicPO = gr.u_basic_value.getCurrencyValue();
var basic = parseFloat(basicPO).toFixed(2);
total = parseFloat(total) + parseFloat(basic);
}
return total;
},