- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 05:47 AM
Hi,
I have a decimal field Payback period but it does not show decimal value.
19350/252 = 77.4 but it shows only 77.
Client script for that is,
Thanks,
Vaishnavi
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 06:53 AM
script i have tested on my personal instance and worked.
function onSubmit() {
//Type appropriate comment here, and begin script below
var currency_amount = g_form.getIntValue('total_costs');
var currency_code = g_form.getIntValue('score');
g_form.setValue('u_mytest', currency_code/currency_amount);
}
u_mytest was initially as "integer" type . and i had more than 20 record which was holdig the value, i just deleted and changed the type and then applied onSubmit client script to set the value and its setting as decimal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 06:51 AM
Hmmm. I dont know why its not working. The code worked in OOB actually.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 06:53 AM
script i have tested on my personal instance and worked.
function onSubmit() {
//Type appropriate comment here, and begin script below
var currency_amount = g_form.getIntValue('total_costs');
var currency_code = g_form.getIntValue('score');
g_form.setValue('u_mytest', currency_code/currency_amount);
}
u_mytest was initially as "integer" type . and i had more than 20 record which was holdig the value, i just deleted and changed the type and then applied onSubmit client script to set the value and its setting as decimal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 06:55 AM
Sure. I will test with this?
But do you think there can be any other issue that I am missing?
Because the background script also does not work. Technically it should work 😞
On form load it shows decimal value. But after it completely loads it doesnot show.
Thanks,
Vaishnavi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 07:02 AM
As i have not faced any issue in past and now so hard to say the exact point. for safest side, create new one .
as you are on development env so its not that late.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 05:53 AM
https://servicenowguru.com/system-definition/controlling-decimal-field-places/
Hope this link helps, btw, you use the .toFixed(2) on var a2,
var A2= .....toFixed(2);