function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kent ManningKent Manning 

How to format European currencies in Visualforce?

I have a quote visualforce page that is rendering as a PDF.  Our offices in Germany and the UK would like to start using the quoting functions, but one of the requirements is that the currency fields display properly.  Here is an example of the code from the Visualforce page:

 

 <apex:column headerValue="Price Extension">
                <apex:outputText value="{0, number, £###.###.##0,00}">
                    <apex:param value="{!item.TotalPrice}"/>
                 </apex:outputText>
            </apex:column>

 The only problem is my Quote "Total Price"  does not format properly.  The output is £42,900.00 when it should be £42.900,00 - Note the position of the comma and period.  Is there any way to get this to work for Europe?  If the Java Message Format will not work, how would i go about getting the price fields to be formatted properly?

 

Any suggestions or help would be appreciated.

Alex.AcostaAlex.Acosta

If this is a currency field you should be able to just use apex tag outputField

 

<apex:outputField value="{!item.TotalPrice}" />

 

Reference:

http://developer.force.com/cookbook/recipe/formatting-a-currency

Kent ManningKent Manning

Thanks Alex for you reply.  However when I tried your suggestion, the following message appeared:

 

ErrorError: Currency fields on entities with effective dated currency are not supported.
 <apex:column headerValue="Unit Price">
      <apex:outputField value="{!item.ListPrice}"/> 
</apex:column>

 Now what?  Seems that I'm going to have to do this with a method on the page controller.  There doesn't seem to be a simple solution for this built into Salesforce. 

 

If anyone has suggestions on how to accomplish this, I would greatly appreciated it -  and the sooner the better! 

 

Thanks.

 

Kent

 

 

 

 

 

 

 

 

Alex.AcostaAlex.Acosta

This idea has apperently been around for quite some time...

 

http://success.salesforce.com/ideaView?id=087300000007kSc

 

I also noticed your outputText may be the cause of some issue from my guess looking at other examples...

 

try changing the line you have from

<apex:outputText value="{0, number, £###.###.##0,00}">

to

<apex:outputText value="{0, number, £###.###.###,00}">

 

See if this will give you the correct output you wanted. Lastly, do you have the proper currency for your user information?

Kent ManningKent Manning

Hi Alex,

 

I tried this <apex:outputText value="{0, number, £###.###.###,00}"> and get this error:

Error	Error: The number format pattern for <apex:outputText> is invalid.

 The visualforce page will not save as a result of this error.

 

  I've also tried escaping the characters with \ and with \\ as shown but that doesn't work either.

 

     <apex:outputText value="{0, number, £###\.###\.###\,00}">

 

From the digging that I've been doing it seems that the Java MessageFormat will only work with currencies that have a #,###0.00 format.

 

The thing that puzzles me is why doesn't visualforce have a provision for formatting currencies.  The normal ui in salesforce formats the numbers and currency properly based on your local in the profile so why doesn't visual force have that same behavior?  Doesn't make sense.

 

Kent

Alex.AcostaAlex.Acosta

Looks like you should make a wrapper class which holds your current Sobject record and add a string field to this wrapper. You'll have to format the currency and display this as a string to get it to work as you want. I've been playing around but I haven't had any luck either

Jim Bedford-Roberts 11Jim Bedford-Roberts 11

For those that follow, there seems to be a typo above resulting in the 'The number format pattern for <apex:outputText> is invalid' message reported. Rather than:
{0, number, £###.###.###,00}
try
{0, number, £###,###,###.00}

At any rate, that works for me.