I have defined a Number field in a custom object with length 18 and 0 decimal places (Number(18, 0)
). User can still enter a decimal value in page layout, but on saving the record, it removes anything after the decimal. So
- if user enters 18.4, it's saved as 18.
- if user enters 18.9, it's saved as 18.
I would like to throw an error if the user enters a decimal value. So I created a before update trigger and thought to throw an exception if I receive a decimal value. But when I tried to read the value in debug logs, I found the value to be an integer (in both the examples above, the value printed was 18). How can I solve this problem?