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!

  • I'm not saying it's a duplicate but go check out salesforce.stackexchange.com/questions/4448/… – eyescream Jan 7 '14 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 '14 at 10:03
  • oops this answer was there in stack...........as mentioned by @eyescream – Sindoora Jan 7 '14 at 10:06
  • @Sindoora: Manually defining all Symbols for all ISO Codes seems not to be an elegant or even feaseable solution for me. – Robert Sösemann Jan 7 '14 at 11:39
  • 1
    @RobertSösemann yup i agree – Sindoora Jan 8 '14 at 10:03
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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.