0

I have a discount and currency field,

While saving formula, currency field gets filed in,

While saving currency , discount field should get filled in.

However, The problem is , Salesforce by default is taking 3 values internally , inspite of only 2 allowed

1

Eric's comment link Why is the field of data type number storing more numbers in decimal places than defined? contains the key point that the field rounding is performed in user interface logic and if you bypass that by setting a value through Apex code (or a formula based on your experience) you can get more decimal places.

Generally its a bad idea to show users one number (with the UI doing the rounding) but end up using a different number in internal logic as resulting values can end up wrong. For example if three values of 33.3333 are presented rounded as 33.33, a user might expect the sum of those numbers to be 99.99. But if the sum logic is using all 4 decimals the sum will be 100.00.

So in Apex code, make a setScale call (or otherwise round) just before persisting. In formulas there is a ROUND function available.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.