3

Is there any way to get a currency symbol in Apex or Visualforce knowing CurrencyIsoCode?

I need it to display the full price of a product (value and symbol) in Visualforce Mail.

2 Answers 2

4

I don't know of a standard way in salesforce to do this. In my own code I use this map

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' => '¥',
        'JPY' => '¥',
        'KHR' => '៛',
        'KRW' => '₩',
        'KZT' => '₸',
        'LBP' => '£',
        'NGN' => '₦',
        'NOK' => 'kr',
        'PHP' => '₱',
        'PYG' => '₲',
        'RUB' => '₽',
        'SDG' => '£',
        'SEK' => 'kr',
        'SHP' => '£',
        'SYP' => '£',
        'TRY' => '₺',
        'USD' => '$',
        '' => '¤' // The currency sign ¤ is a character used to denote an unspecified currency.
};

to get the symbol based on the currency code. I only included the ones that have an actual symbol, but you could create a more complete map based on the list on wikipedia https://en.wikipedia.org/wiki/Currency_symbol

3
  • I also was thinking about it... but it is so dirty :(
    – Rechu
    Dec 15, 2021 at 12:45
  • True. You could probably make a custom object for it that you refresh with some webservice that provides the data, you can probably find a bank or some company with a service like that. But that would be a lot of work for the off chance that some country invents a new currency and you actually have to use it in your org. I chose the cheap and easy option and haven't had complaints yet.
    – H Alves
    Dec 15, 2021 at 12:53
  • 1
    Well, a Custom Metadata object could solve this, and would be accessible basically everywhere.
    – sfdcfox
    Dec 15, 2021 at 13:47
-1

try this

    <apex:outputText label="NRR" value="{0,number}">
    {! Opportunity.CurrencyIsoCode} &nbsp;
    <apex:param value="{! Opportunity.NRR__c}" />
    </apex:outputText>

This gives you the Currency symbol as well as the value, in proper format.

4
  • Unfortunately, what i want to get is for instance $3.25, but with your approach i got USD 3.25 instead
    – Rechu
    Dec 15, 2021 at 11:16
  • <apex:outputText value="{0, Number, Currency}"> go for this then. Dec 15, 2021 at 11:21
  • 1
    it gets the currency from user's locale, but i want currency from the record instead
    – Rechu
    Dec 15, 2021 at 11:23
  • Sorry for replying very late, you can try this as well <apex:outputField value="{!O.Amount}"/> Jun 14, 2022 at 10:35

You must log in to answer this question.

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