- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 03:39 AM
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
Could someone please explain this behavior? Does the currency field has some restrictions?
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 10:25 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 09:39 PM
Hi @shivangi k ,
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;
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 10:25 PM
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