Loading

Round Off Decimal Values of Currency Fields in the Salesforce UI and API

Дата публикации: Jun 11, 2025
Описание

When you create a custom currency field and define the number of decimal places (e.g., 2), Salesforce applies rounding only in the user interface. The full precision value is still stored in the database.

User Interface (UI):
If a user enters a value such as $1.234 into a field set to 2 decimal places, the UI will display $1.23 after saving. However, if the user re-edits the field, the full value ($1.234) is shown. This rounding is purely visual.

API Input (e.g., REST API, Apex, Data Loader):
Salesforce does not round values provided through the API. If you insert or update a value like $1.234, it will be stored exactly as entered, regardless of the field’s decimal setting.

This behavior is intentional and ensures backward compatibility with external systems and integrations. If consistent rounding is required, it must be handled explicitly in code or integration logic.

Решение
Some workarounds you can use to ensure that this behavior does not cause issues in your Org are:
  • Round the currency value before using web callouts to APIs that expect 2 decimal places. 
  • Add display logic in the UI to round values to 2 decimal places. 
  • Write an "after insert/update" trigger to round the value to 2 decimal places. 
  • Create a formula field that takes the value of the currency field and rounds it to 2 decimal places. 
Дополнительные ресурсы

Product Price 'More Decimals on Price' feature

Номер статьи базы знаний

000385689

 
Загрузка
Salesforce Help | Article