Decimal fields truncate trailing zeroes?

Not applicable

I have created a form with several decimal fields that I want to be formatted as #.##

However, upon save to the database table, the traling zeroes are removed. For example, 1.00 gets set to 1. And 2.50 gets set to 2.5. I would like for all of my numbers to have a certain precision so they line up when displayed in a list. I reviewed the forum and tried the scale=2 suggestion, but that doesn't work. I created a client script that take the field and formats it as #.## using JavaScript. However, as soon as the record is saved, the trailing zeroes/formatting are removed.

Any idea on how to do this or if it's possible?

Thanks!

10 REPLIES 10

tony_fugere
Mega Guru

I'm guessing currency isn't the right option, but if your field represents money, it supports this.

If you are trying to represent a decimal with this format that is not money, I think we're out of luck. You might be able to do it with a string field, but then you'll likely lose list calculation features.


Mark Stanger
Giga Sage

I've never been able to get this to work correctly until now. It turns out it's actually a combination of Max length for the field and the scale attribute. Check out this link for details.

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


This worked great. I changed the Field type to decimal. No issues worked a charm.


wattsj
Kilo Expert

Wanted to bump this post to see if anyone has figured anything out before I dive in to try to figure this out. My biggest complaint with the Currency type field is that you can't list edit the value.