+ Start a Discussion
Daniel AhlDaniel Ahl 

Lightning:datatable currency field in multiple-currencies org.

I have a question that I'm having a hard time explaining and solving.
So for starters, I've built an aura component where I want to use Lightning:datatable to enter the Amount of an Opportunity that looks like this:

(This is not the actual component I want to use, but for this one I've built an example for better explanation.)


<aura:component controller="testController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="recordId" type="String"/>
    <aura:attribute name="data" type="Object"/>
    <aura:attribute name="columns" type="List"/>
    <aura:attribute name="errors" type="Object" default="[]"/>
    <aura:attribute name="draftValues" type="Object" default="[]"/>

    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    <div style="height: 300px">
            columns="{! v.columns }"
            data="{! v.data }"
            errors="{! v.errors }"
            draftValues="{! v.draftValues }"
            onsave="{! c.handleSaveEdition }"

	init : function(cmp, event, helper) {
		cmp.set('v.columns', [
            {label: 'Opp Name', fieldName: 'Name', type: 'Text', editable: false },
            {label: 'Amount', fieldName: 'Amount', type: 'currency', typeAttributes: {currencyCode: { fieldName: 'CurrencyIsoCode' }}, editable: true}
    handleSaveEdition: function (cmp, event, helper) {
        var draftValues = event.getParam('draftValues');
        helper.saveEdition(cmp, draftValues);

    fetchOpps : function(cmp) {
        let getOpp = cmp.get('c.getOpp');
        getOpp.setParams({OppId : cmp.get('v.recordId')});
        getOpp.setCallback(this, function(response){
            if(response.getState() == 'SUCCESS'){
                cmp.set('v.data', response.getReturnValue());
    saveEdition : function(cmp, draftValues) {
        var self = this;
        let saveOpps = cmp.get('c.saveOpps');
        saveOpps.setParams({opps : draftValues});
        saveOpps.setCallback(this, function(res){
            if(res.getState() == 'SUCCESS'){
                cmp.set('v.errors', []);
                cmp.set('v.draftValues', []);
            } else if (res.getState() === "ERROR") {
                var errors = response.error;

Apex Controller = testController.apxc
public class testController {
    public static List<Opportunity> getOpp(String OppId){
        return [SELECT Id, Name, CurrencyIsoCode, FORMAT(Amount) FROM Opportunity WHERE Id =: OppId];
    public static void saveOpps(List<Opportunity> opps){
        update opps;

Organization information:
Currency: SEK

Enabled currencies: SEK and USD, both having 2 decimal places.

So the issue I have is that this component is behaving odd.
My locale is Swedish, the Opportunity Currency is set to USD.

When I edit the amount field to be 123,45 and save, the saved value is: 12 345,00 US$.

Why is that?
One more question, if I set the value to 123,4 it gets turned into 123,40 US$ but the value is saved as 12,00 US$.

The reason to why I'm using FORMAT(Amount) is because I would like to have the value to be the local currency setting for the record, even when using multi-currencies, but for now this won't let me use decimals for this.


Images for trying to explain further:

The amount start at 12,00 US$
So the Opporunity starts with an Amount of 12,00 US$.
I want to set it to 12,34:

User-added image
After saving and retrieving record from database again:
User-added image

Best Answer chosen by Daniel Ahl
Daniel AhlDaniel Ahl
Solved it by sending as a string to Apex-class, then deserializing it into a list of Accounts.
public static void saveAccounts(String AccountList){
  List<Account> Accounts = (List<Account>)JSON.deserialize(AccountList, List<Account>.class);
  update Accounts;


All Answers

Caleb Kuester 35Caleb Kuester 35

It might have something to do with the fact that, in the United States, $123,45 is going to be represented as $123.45 (not a comma, but a period). I don't know if this can be changed in your org's localle settings.

For your "one more question," check to make sure your field (back-end) is capable of storing decimals. You would go to your sobject definition page and then go to the field itself. Check to make sure it's something like 9,2 and not 9,0. (nine integer places and two decimal places).

Daniel AhlDaniel Ahl

Yes, I know that, but I built this solution and tested it. And when I did, it worked.

Now it has stopped working for some reason, and I don't know why, even if the Opportunity has Swedish currency, and I have Swedish Locale on my account, the decimals doesn't work.

The field itself is set to be a currencyfield with 16,2 in length. (2 decimal places) :(

Daniel AhlDaniel Ahl
Solved it by sending as a string to Apex-class, then deserializing it into a list of Accounts.
public static void saveAccounts(String AccountList){
  List<Account> Accounts = (List<Account>)JSON.deserialize(AccountList, List<Account>.class);
  update Accounts;

This was selected as the best answer