1

Is there a way to get the symbol (€ not EURO) of an orgs default currency via Apex or a Visualforce global variable?

I know how to get the ISO Code:

SELECT IsoCode
FROM CurrencyType
WHERE IsCorporate = true

Note: Must work in Multi-Currency Orgs!

6
  • I'm not saying it's a duplicate but go check out salesforce.stackexchange.com/questions/4448/…
    – eyescream
    Jan 7, 2014 at 9:19
  • 1
    public static String currencySymbol(String iso) { String symbol = null; if (iso=='ALL') { symbol='Lek'; } else if (iso=='USD') { symbol='$'; } else if (iso=='ARS') { symbol='$'; } else if (iso=='AWG') { symbol='ƒ'; } else if (iso=='AUD') { symbol='$'; } else if (iso=='BSD') { symbol='$'; } else if (iso=='BBD') { symbol='$'; } } currencySymbol('GBP'); currencySymbol('USD'); Returns ‘£’, ‘$’ .You have to define all the currency.
    – Sindoora
    Jan 7, 2014 at 10:03
  • oops this answer was there in stack...........as mentioned by @eyescream
    – Sindoora
    Jan 7, 2014 at 10:06
  • @Sindoora: Manually defining all Symbols for all ISO Codes seems not to be an elegant or even feaseable solution for me. Jan 7, 2014 at 11:39
  • 1
    @RobertSösemann yup i agree
    – Sindoora
    Jan 8, 2014 at 10:03

2 Answers 2

1

Try this trick on Javascript to get the symbol:

  1. Use a currency field or Add a fake custom field to any object.
  2. Print that field on an outputField
  3. Get the printed value by JS and remove the digits, dots and spaces
  4. Use the symbol to be displayed where ever you need. (for example: you could assign this by js to span.symbol).

sample code:

 <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"  />
 <apex:outputField value="{!Account.amount__c}"  id="amount" style="display:none;" />
 <span class="symbol"></span> <span>3333</span> 
 <script> 
      var symbol = $('span[id$=amount]').text().replace(/\d+|\s+|\.+/g,'');
      alert(symbol);
      $('span.symbol').text(symbol);
  </script>
1

I think we should copy the answer from a similar questions and answers.

public static String getCurrencyIsoCode(SObject record){
    return UserInfo.isMultiCurrencyOrganization() ? (String) record.get('CurrencyIsoCode') : UserInfo.getDefaultCurrency();
}

public static String getCurrencySymbol(SObject record) {
    return getCurrencySymbolFromIso(getCurrencyIsoCode(record));
}

static Map<String, String> currencySymbolsByIsoCode = new Map<String, String>{
    'AUD' => 'A$',
    'AWG' => 'ƒ',
    'BDT' => '৳',
    'CAD' => 'CAD$',
    'CNY' => '¥',
    'CRC' => '₡',
    'DKK' => 'kr',
    'EGP' => '£',
    'EUR' => '€',
    'FKP' => '£',
    'GBP' => '£',
    'GIP' => '£',
    'ILS' => '₪',
    'INR' => '₹',
    'ISK' => 'kr',
    'JPY' => '¥',
    'KHR' => '៛',
    'KRW' => '₩',
    'KZT' => '₸',
    'LBP' => '£',
    'NGN' => '₦',
    'NOK' => 'kr',
    'PHP' => '₱',
    'PYG' => '₲',
    'RUB' => '₽',
    'SDG' => '£',
    'SEK' => 'kr',
    'SHP' => '£',
    'SYP' => '£',
    'TRY' => '₺',
    'UAH' => '₴',
    'USD' => '$',
    '' => '¤' // The currency sign ¤ is a character used to denote an unspecified currency.
};

public static String getCurrencySymbolFromIso(String code) {
     String currencySymbol = currencySymbolsByIsoCode.get(code);
     return currencySymbol == null ? '¤' : currencySymbol;
}

I agree that manually defining all Symbols for all ISO Codes is not an elegant or feasible solution. However, it is currently the only solution unfortunately.

Unless we encourage everyone to vote for ideas like this https://ideas.salesforce.com/s/idea/a0B8W00000GddS5UAJ/from-apex-get-the-currency-symbol-in-a-single-currency-org to provide an option for us to have elegant and feasible solution.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .