4

I am developing a custom currency field with lightning:input type="number" formatter="currency" component:

<lightning:input type="number" formatter="currency" value="100" step="1"/>

I have enabled in my org the Multiple Currencies feature so each record's amounts can be declared with different currencies

This means that sometimes my custom field will contain USD numbers and sometimes ILS (Israeli currency). and the symbol near the number value needs to change accordingly.

On the view mode of my component, I am using this:

<lightning:formattedNumber style="currency" currencyCode="{!v.record.CurrencyIsoCode}" currencyDisplayAs="symbol" value="100"/>

and it works perfect!

PROBLEM

In the lightning:input component the currency symbol is displayed according to the user's local currency and not according to the record's defined currency.

for example - this is how a field looks like when it's record is defined as USD, but it displays in ILS:

enter image description here

QUESTION

Is there a way to define the lightning:input component to change the currency symbol?

If not - what is the best approach to show the right symbol (I have the CurrencyIsoCode field in my code and can use it)

1

I have the same issue here. I talked with Salesforce support about that almost a year ago, but they haven't provided a proper solution for that using the lightning:input component yet.

Note a single user would require to create records in multiple currencies. But apparently, Salesforce Lightning product developers failed to analyse that requirement.

The lightning:input component should include a currencyCode attribute that receives a currency ISO code and renders the value with the proper currency sign. I'm still waiting for that capability.

The work around is to use ui:inputCurrency and set the format attribute (i.e. £#,###.00), but if you have a form built using only lightning namespace components, then that will require additional effort to make ui:inputCurrency look and feel the same. You can also build your own component as well, but I guess you shouldn't be reinventing the wheel.

  • Thanks @OscarBecerra, eventually what I do is - not using the multiple currency feature of SF and just using a currency field, then I can use <lightning:input type="number" formatter="currency" name="apiName" value="{!v.value}" currencyCode="{!v.currencyCode}" step="1" /> and set the currency code as I want – Itai Shmida Dec 16 '18 at 8:18

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.