Loading

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

Publiceringsdatum: Jun 3, 2026
Beskrivning

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

Behavior in the Salesforce User Interface (UI)

If a user enters a value such as $1.234 into a currency field configured for 2 decimal places, the UI displays $1.23 after saving. However, if the user re-edits the field, the full value ($1.234) is shown. This rounding is purely visual and does not affect the stored value.

Behavior via API (REST API, Apex, Data Loader)

Salesforce does not round values provided through the API (Application Programming Interface). The Salesforce API refers to the programmatic interfaces — such as the REST API, Apex code, and the Apex Data Loader — that allow external systems to read and write Salesforce data. If you insert or update a value such as $1.234 via the API, it is stored exactly as entered, regardless of the field's decimal setting.
For example, if your integration sends $1.2345 via the REST API to a field configured for 2 decimal places, Salesforce stores $1.2345 — not $1.23. To prevent downstream calculation issues, round the value before sending it to Salesforce.
This behavior is intentional and ensures backward compatibility with external systems and integrations. If consistent rounding is required across both UI and API, it must be handled explicitly in code or integration logic.

Lösning

Workarounds to Ensure Consistent Decimal Rounding

The following workarounds can be used to prevent decimal precision issues in your Salesforce org:

  • Round the currency value before making API callouts to systems that expect 2 decimal places.
  • Add display logic in the Salesforce UI (using formula fields) to round values to 2 decimal places for display purposes.
  • Write an Apex "after insert/update" trigger to round the value to 2 decimal places immediately after a record is saved via the API.
  • Create a formula field that takes the value of the currency field and rounds it to 2 decimal places using the ROUND() function.
Ytterligare resurser

Salesforce Help: Product Price Decimal Precision Feature (More Decimals on Price) : https://help.salesforce.com/articleView?id=000325726&language=en_US&type=1&mode=1

Knowledge-artikelnummer

000385689

 
Laddar
Salesforce Help | Article