I want to display the currency field with all the decimal places.Right now salesforce automatically rounds it to two decimal places. salesforce displays 123.45678 as 123.46 ,i want it to be 123.45678 on the detail page,it displays as 123.45678 on edit page.Is there any way to do it?!
4 Answers
Take a look at the docs on apex:outputText. You can use the Java MessageFormat format strings.
For example, the following will display US currency with six decimal places, formatted with comma separators, up to 999 trillion dollars and will always show six digits to the right of the decimal place due to the zeroes. This is Visualforce, though.
<apex:outputText value="{0, number, $###,###,###,###,##0.000000}">
<apex:param value="{!myObject.My_Value__c}"/>
</apex:outputText>
You can specify the decimal values for the field as shown in above screenshot
-
I had declared it with 6 decimal places,but on saving the record it rounds it to 2 decimal places.I dont see any image in your post Commented Oct 24, 2012 at 14:11
-
1Is your page a visualforce page or a simple standard detail page ? Commented Oct 24, 2012 at 14:13
-
As you can see i did a demo in my developer and its working to display all the digits as i want Commented Oct 24, 2012 at 14:23
-
I've verified @MohithKumar 's solution in my Dev Org; created a new custom currency field with 6 decimal places and it displayed as expected (currency locale set to US.) Commented Oct 24, 2012 at 17:00
-
I want to display all the decimal on the standard detail page. Commented Oct 25, 2012 at 5:41
Currency fields are formatted according to the record's currency (ISO code) and the org currency setup (Company Profile - Manage Currencies).
You have several options:
Change the number of decimal places for the currency as a whole (perhaps unlikely that this will be what you want - as this will change the formatting of all currency values everywhere for that currency)
Change the type of your field from "currency" to "number"
Add a formula field where the output type is number and is set to 6dp, where the formula simply references your existing currency field
I have modified the currency settings under the manage currencies section.
-
1I have just updated my answer relating to this option - this will change the formatting of EVERY currency field when using this currency Commented Oct 26, 2012 at 8:07
-
If my answer guided you please mark the answer - thanks :-) Commented Oct 27, 2012 at 12:28