5

I am using multiple currencies in my project and I have the currency ISO code. But the problem is, I want to get the symbol for currencies other than user locale. Is there any solution available for this? Example :

in Lighting JS $A.get('$locale.currency') will return the user locale currency. I want to get the symbol for other currencies which are available in my org, Like Euro, Yen, etc.

3
  • 1
    At what point of time would you want to get the other currencies displayed? Like how do you choose if USD vs. Euro vs. Yen should be displayed?
    – Jayant Das
    Sep 24, 2018 at 17:46
  • I want to show it on the chart. In which I am passing the CurrencyISOCode. Oct 20, 2018 at 17:02
  • @TariqueShamim - what I did was just create a simple JS map of currency code to symbol. You can get a map from github.com/bengourley/currency-symbol-map/blob/master/map.js, for example. If you want it as a utility to use throughout your project, consider making a simple js module out of it, or include it in a utils module.
    – jbyrd
    Dec 1, 2021 at 16:01

2 Answers 2

0

lightning:formattedNumber allows you to pass a currency code dynamically and will render the appropriate symbol. All you need to do is in the init method set the currencyCode attribute to the current users iso code

example:

<lightning:formattedNumber value="10.00" style="currency" currencyCode="{!v.currencyCode}"/>

will render as $10.00 if the users ISO code is USD

Heres a link to the documentation

1
  • 2
    I know to use this one in lightning. But if I am using it on a chart which is created using using the chartJS library, then I need to show it on the charts. So, I will need some method which returns currencyISOSymbol for the code, so that I can set it on the chart. Oct 20, 2018 at 17:04
0

Yes, there is a solution to get the symbol for other currencies in Salesforce. You can use the $Locale.getCurrencySymbol(currencyIsoCode) method in Lightning JS to get the currency symbol for a specific currency ISO code. Here's an example:

var currencyIsoCode = "EUR";
var currencySymbol = $A.get("$Locale.getCurrencySymbol(currencyIsoCode)");
console.log(currencySymbol); // Output: "€"

Note: This method returns the currency symbol for the currency ISO code specified in the currencyIsoCode variable. It does not return the user locale currency symbol.

1
  • When I try to use it, I receive an error: LWC1503: Do not use $A in LWC code
    – Patlatus
    Feb 15 at 11:26

You must log in to answer this question.

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