0
 component.set('v.ProductsColumn', [
        {label: 'Carton Value', fieldName: 'Test_Currency__c', type: 'currency',typeAttributes:{minimumFractionDigits :'4',currencyCode: { fieldName: component.get("v.oppRecord.CurrencyIsoCode")}}}
    ]);

Im using a lightning datatable in my component and displaying a field called Test_Currency__c(dataType of Currency) in UI. I have enabled multi currency and Organizations corporate currency is AUD. If the Test_Currency__c field's currency is other than AUD(ex:say EUR), it is displayed as EUR 239,000 If it is euivalent to corporate currency means ,it is displayed as $239,000.Instead of dollar I need to display as AUD 239,000.

UI datatable

Any help on this would be greatly appreciated

2 Answers 2

2

The fieldname should be the actual field name of the record, from where you need to copy the currency code. But in your code, it looks like you are fetching the actual value.

Here is the correct code.

component.set('v.ProductsColumn', [
        {label: 'Carton Value', fieldName: 'Test_Currency__c', type: 'currency',typeAttributes:{minimumFractionDigits :'4',currencyCode: { fieldName: 'CurrencyIsoCode')}}}
    ]);
0

Your question seems to have two parts:

  1. Use the org's currency rather than the current record/user's
  2. Display using the ISO code (AUD) rather than the currency symbol ($)

(1) is basically answered by Rahul, you need to set a typeAttribute to the cell of currencyCode: { fieldName: '<your currency field>')}, then set it in the record data. This is meant to be used to support dynamic currencies, e.g. with a Product_Currency__c field on your custom Product__c object. In the usual case, you'd set "AUD" or "EUR" on your Product__c records, query it, then the datatable looks for the currency ISO code in whatever field you specified (in this case, "<your currency field"> is Product_Currency__c). But you want to use the org currency, not a dynamic one from the records. Probably easiest to iterate over the records and set your own currency ISO code property, something like:

records.forEach( record => {
    record.CurrencyIsoCode = 'AUD';
});

(2) is much simpler. Add the typeAttribute currencyDisplayAs: "code". E.g.

component.set('v.ProductsColumn', [
    {
        label: 'Carton Value',
        fieldName: 'Test_Currency__c',
        type: 'currency',
        typeAttributes:{
            minimumFractionDigits: '4',
            currencyCode: {
                fieldName: 'CurrencyIsoCode'
            },
            currencyDisplayAs: "code"
        }
    }
]);

You must log in to answer this question.

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