0

I am having real issues passing a list of my Transaction__c object from my lightning controller into my apex controller my transactions apex:attribute is like so:

<aura:attribute name="transactions" type="Transaction__c[]"/>

And my lightning controller method is:

addTransactions : function(component, event) {
//var transactionList = component.get("v.transactions");
var action = component.get("c.insertTransactions");
    action.setParams({
        tList : component.get("v.transactions")
    })
    action.setCallback(this, function(response) {
        var state = response.getState();
        if(state === "SUCCESS"){
            alert("From Server: " + response.getReturnValue());
        }
        else{
            console.log('ERROR:' + state + response.getError());
        }
    });
    $A.enqueueAction(action)
}

And my apex controller method is:

@AuraEnabled
public static List<Transaction__c> insertTransactions(List<Transaction__c> tList) {
    try{
    insert tList;
    }
    catch(exception e){
        System.debug('error inserting transactions @ ' + e);
    }
return tList;
}

In the console log the error I am recieving is:

ERROR = message: Unable to read sObject

enter image description here

Is there a specific way to pass lists because I must be missing something.

An example of the array that would be passed looks like this in the console:

enter image description here

4
  • @Nebbyyy I didn't realize you'd tagged this as apex, so this was automatically closed, but the question I linked would appear to solve your issue. Please let us know if that's not the case, and we'll be glad to reopen your question once you edit it to provide additional information.
    – sfdcfox
    Nov 1, 2017 at 17:56
  • Did you check that the running user has read access to Transaction__c?
    – Adrian Larson
    Nov 1, 2017 at 18:36
  • Yeah user has system admin
    – Nebbyyy
    Nov 1, 2017 at 18:51
  • Maybe the Duplicate Mark(or question) for this should be removed - they both are different !? Apr 2, 2019 at 14:31

0

Browse other questions tagged .