Find your content:

Search form

You are here

How to access the Organization "Currency Locale" ISO Locale code (NOT Currency code) in Apex/SOQL

 
Share

First of all, before telling me that this is a duplicate of the previously-asked question "Display currency symbol", READ THE WHOLE QUESTION.

Summary: I am trying to replicate the functionality of the Salesforce.com "Currency" field type in a Single-Currency org, but cannot because I cannot find the ISO Locale code of the Organization Currency Locale (which, for single-currency orgs, defines BOTH the ISO Locale that will be used for formatting currency number values AND the ISO Currency code that will be used to prepend/append a corresponding currency symbol.

For Single-Currency orgs, the Organization-wide "Currency Locale" field, which MUST, I believe, behind the scenes consist of BOTH an ISO Currency Code (e.g. USD, EUR) AND an ISO Locale Key (e.g. en_GB, fr_FR). The reason that it must consist of BOTH the ISO Country Code and Locale Key is that this information is necessary in order for Salesforce.com to render Currency fields, which take a Double value, apply a locale-specific Number Format to it, and then prepend/append the ISO Currency Code's associated symbol (e.g. '$').

The Organization "Currency Locale" field can be edited by going to Setup > Company Profile:

Company Profile - Currency Locale field

However, as far as I can tell, this field is NOT available on either the Organization object, User object, or through any Apex system class (e.g. UserInfo). UserInfo.getDefaultCurrency() returns, helpfully, the ISO Currency Code part of the Currency Locale field. However, there is no way to get at the locale half of the field!

This is a problem because there is a one-to-many mapping between ISO Currency Codes and Currency Locales. For instance, according to [Salesforce.com's list of supported locales] (http://help.salesforce.com/help/doc/en/admin_supported_locales.htm), the 'EUR' ISO Currency Code is used by 37 different supported user locale codes, e.g. it_IT, fr_FR. But not all of these locale codes have the same number format. For instance, examine the following Number Formats for ISO User Locales that use the 'EUR' ISO Currency Code:

  • it_IT: 1.234,56
  • fr_FR: 1 234,56
  • en_IE: 1,234.56

So what's the big deal? Well, you can't rely on an Organization's Currency Locale being the same as a User's configured Locale, so there's no (supported) way, in Single Currency orgs, to determine the Currency Locale to use to render currencies in that locale's number format UNLESS you use the Salesforce.com Standard UI or apex:inputField.

Here's an example of a Contact detail page with 2 fields, one a Number, and one a Currency, with the number format of each being different on account of the difference between Organization Currency Locale and User Locale:

sample Contact detail page

From a totally custom Visualforce UI, e.g. NOT using apex:inputField or the standard UI, I can properly format the Number field "Total Mass (Grams)" because I can access the User's Locale through UserInfo.getLocale(), which here is set to 'en_US'. However, I cannot replicate the "Net Worth" field, a Currency field, because the Organization's Currency Locale information (which is set to 'fr_FR'), is not available from Apex/SOQL.

If anyone can find a way to retrieve this information from Apex / SOQL, I would be very thankful!

EDIT For confirmation that this info is not accessible from Apex/SOQL/Web-Services-API, I discovered that there is an Idea posted about this (with woefully few votes--- VOTE IT UP!):

Idea: 'Default Time Zone' and 'Currency Locale' available on the Organization Object


Attribution to: zachelrath

Possible Suggestion/Solution #1

It appears that this info is not accessible from Apex/SOQL/Web-Services API - here is a link to an Idea posted about this (with woefully few votes---vote it up!

Idea: 'Default Time Zone' and 'Currency Locale' available on the Organization Object


Attribution to: zachelrath
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/5638

My Block Status

My Block Content