Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Decimal type field does not show decimal value.

Vaishnavi35
Tera Guru

Hi,

I have a decimal field Payback period but it does not show decimal value.

find_real_file.png

19350/252 = 77.4 but it shows only 77.

Client script for that is,

find_real_file.png

Thanks,

Vaishnavi

1 ACCEPTED SOLUTION

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. 

View solution in original post

29 REPLIES 29

Hmmm. I dont know why its not working. The code worked in OOB actually.

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. 

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

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. 

Sukraj Raikhraj
Kilo Sage

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);