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
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:
Transaction__c
?