how to retains decimal field 2 places after record submits

georgechen
Kilo Guru

I am stuck at a decimal field cosmetic where the 2 places need to present always, for example, if users enter 123.00, the .00 need to stay when the record is submitted.

In ServiceNow, this is not a difficult thing to do if the field is set to Currency or Price, however, due to the limitation of list editing.   The users are not able to edit in List view; therefore I had to work this around by changing it to a decimal field which allows users to edit, which is great!!

However, the Decimal field does not retain the 2 places after submitting when a whole number is entered, e.g 123.00

find_real_file.png

After submitting the record, the 2 places are gone

find_real_file.png

Is any way to always retain the 2 places all the time.

Thanks.

17 REPLIES 17

Thanks Shloke,


I put a new before business rule on the decimal field to retain the two decimal places.


find_real_file.png



after testing it seems taking no effect on the field despite the BR does fire,


find_real_file.png



but for display, the two places are still missing.       I will need to find other way to tack this.



Appreciate your attempt to help.



Kind regards,


George


Shishir Srivast
Mega Sage

Please have the attribute set as scale=4 for decimal field. Hope that helps.


Reference: https://www.servicenowguru.com/system-definition/controlling-decimal-field-places/


Thanks Shishir; I've tried the scale=4 on the field attribute but it doesn't seem to work.


find_real_file.png



Before update


find_real_file.png


After update


find_real_file.png



I will tackle the business rule toFixed Shloke suggests above.



Regards,


I have tested y'day with toFixed() too but that didn't help. I will try to find another way to achieve if possible and will let you know.


Much appreciated, I will also keep looking for solutions.


Thank you again.


Regards,


George