I’m looking for a way to get the Default currency symbol (in a none-multi-currency org) of the salesforce org locale (to have it displayed on a visualforce page in a field that can’t be
<apex:inputField>
or<apex:outputField>
) preferably query-able from apex (via the database, a describe or whatever) and then again the actual symbol, meaning € for Euro, $ for dollar, and so on…There must surely be some sort of mapping hidden in the code somewhere salesforce does this via the input/outputfields if bound to an sobject of type currency
Can anyone point me in the right direction?
Answer
We ended up fixing it this way, this hasn’t been tested on a multicurrency org but this works on a singlecurrency org.
public static String getCurrencyIsoCode(SObject someObject){
String currencyIso = UserInfo.isMultiCurrencyOrganization() ? (String) someObject.get('CurrencyIsoCode') : UserInfo.getDefaultCurrency();
return currencyIso;
}
public static String getCurrencySymbol(SObject someObject) {
return getCurrencySymbolFromIso(getCurrencyIsoCode(someObject));
}
public static String getCurrencySymbolFromIso(String Iso) {
String currencySymbol =
('USD' == Iso ? '$' :
('CAD' == Iso ? '$' :
('EUR' == Iso ? '€' :
('GBP' == Iso ? '£' :
('JPY' == Iso ? '¥' :
('KRW' == Iso ? '₩' :
('CNY' == Iso ? '元' :
Iso)))))));
return currencySymbol;
}
Attribution
Source : Link , Question Author : pjcarly , Answer Author : pjcarly