5

I was so used to Visualforce fields that display a currency value in the CurrencyIsoCode of the relevant record that it took me a while to understand why in Lightning wrong Iso Codes (those of the browser) are used.

  1. What is the recommended way to make Lightning currency fields behave like in the old times?
  2. Who cares abou the browsers currency if the value already has a database-stored semantic?
  3. Does force:inputField respect the CurrencyIsoCode and how can I make it work for generic (dynamic field name binding) usage?
  4. Which other Lightning component of the force:, lightning:, ui:, namepace can and should be used with currencies and when?
3

Although still in Beta, it looks like the prefered component for currencies is (or will be):

lightning:formattedNumber

which supports currency codes via the currencyCode attribute.

component.cmp:

<lightning:formattedNumber value="5000" style="currency" currencyCode="USD" />

You still need to fetch the currency code from the record though. Or if it is related to a user(s) preference, you can use $Locale, ex:

{!$Locale.currencyCode}

others that can be used (however, dont support the attributes that facilitate formatting and ISO currencies):

  • I was explicitly asking for an input component so lightning:formattedNumber doesn't help here. – Robert Sösemann Apr 4 '18 at 11:27

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.