+ Start a Discussion
SScholtzSScholtz 

Decimal points: data loader allows loading additional points despite field definition?

Scenario: I have a decimal field defined with 4 decimal points of precision.  When entering data through the UI, if you enter additional decimal points, Salesforce will round the number to 4 decimal points and save this value to the database.

Entered in UI: 0.20006
Presented after saving: 0.2001
Saved in the database (using Eclipse to query): 0.2001

When using the Apex data loader, Salesforce does not enforce decimal precision.

CSV file: 1.283265
In the UI: 1.2833
Saved in the database: 1.283265

Attempting a quick edit of the record in the UI will show the rounded version, and formulas use the rounded version, but Apex code will use the value from the database.

The extended decimal value will stay this way until the record is re-saved through the UI. (even a quick edit on an unrelated field will cause the rounded version to be saved to the database)  An update via Apex DML statement will NOT change the value unless it's explicitly modified with Apex.

----

I realize I can prevent the data loader from importing such extended values by using a validation rule, or enforce a rounded value using a BeforeUpdate/BeforeInsert trigger, but why is Salesforce not rounding the values as they come in via the Data Loader?

The behaviour seems inconsistent to me.

Is this a "bug" or a "feature"?

Best Answer chosen by Admin (Salesforce Developers) 
Ron ReedRon Reed

Appirio just had a blog post about this a couple of weeks back you might want to read:

Salesforce and Decimal Places

All Answers

Ron ReedRon Reed

Appirio just had a blog post about this a couple of weeks back you might want to read:

Salesforce and Decimal Places

This was selected as the best answer
SScholtzSScholtz

Great, thanks for the link.  It at least confirms that I'm not crazy.

 

Any consensus on this, on whether it's a "bug" or "feature"?  Should we create an Idea for it?

SScholtzSScholtz

Well, marked your response as the "solution" - Salesforce is behaving the way that other people are seeing, and is accepting values beyond what the field definition is.  I guess when it comes to decimal places, the field definition only works for the UI and doesn't apply any restrictions for Apex or the API, and developers just need to be wary of that.