2

I currently have a lightning component that is displaying variables that hold currency values.

The issue I am having is that I would like to format the currency with commas in the UK format meaning $3250.00 displays with commas --> $3,250.00 (and all other subsequent commas).

I have attempted this solution, both using the js override format and the below example example without luck:

<aura:attribute name="myCurr" type="Decimal" default="50000"/>
<ui:outputCurrency aura:id="curr" value="{!v.myCurr}"/>

What am I doing wrong? Here is my sample code below:

<aura:attribute name="GrossRevenuevalue" type="currency" default="0.00" />

<div class="slds-truncate" style="currency" title="Gross Revenue value"> {!v.GrossRevenuevalue}

Added under function

var recId = component.get("v.recordId");
var curr  = cmp.find("curr");
curr.set("v.GrossRevenuevalue", '$#,###.00');

enter image description here

4

You have to use format attribute of ui:outputCurrency.

your currency field will be like:

<aura:attribute name="GrossRevenuevalue" type="Decimal" default="3250.00" />
Your amount is : <ui:outputCurrency aura:id="curr" value="{!v.GrossRevenuevalue}" format="$##,##,###,###.00"/>

£ or $ depending on currency you wanna use.

enter image description here

Source: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_ui_outputCurrency.htm

  • I have added the following: with no luck: <aura:attribute name="GrossRevenuevalue" type="Decimal" default="50000.00" /> <ui:outputCurrency aura:id="curr" value="{!v.GrossRevenuevalue}" format="$#,###.00'"/> – Geo Apr 20 '18 at 15:17
  • edited answe added code screenshot. – Pranay Jaiswal Apr 20 '18 at 15:43
  • When I enter this my $ value actually shows up blank now. I am not sure why. The code seems correct. I will keep trying and let you know if I am missing something obvious – Geo Apr 22 '18 at 14:56
1

For me a hardcoded locale-specific format always seems odd. Some users might switch their locale to France or German for example and it would be nice that the component supports that.

If you are showing an fieldvalue you could try lightning:outputField

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_outputField.htm

1

"¤#,##0.00" ¤ represents the currency sign, which is replaced by the currency symbol.

please check with this link. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_locale_value_provider.htm

0

You need to provide the format in ui:outputCurrency itself.

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.