I've looked through the various questions here on this topic but still can't find the solution.

I'm trying to upsert a list of records, but keep getting the above error. Code snippets below, any suggestions appreciated.

<div class="slds-p-around--small slds-align--absolute-center">
    <lightning:button variant="brand" label="Save" onclick="{!c.createTimesheet}" />


createTimesheet : function(component, event, helper){
    var newTimesheet = component.get("v.timesheets");
    helper.createTimesheet(component, newTimesheet);


    createTimesheet : function(component, timesheets){
    this.upsertTimesheets(component, timesheets, function(response){
        var state = response.getState();
        if (state === "ERROR") {
            var errors = response.getError();
            if (errors) {
                if (errors[0] && errors[0].message) {
                    console.log("Error message: " + 
            } else {
                console.log("Unknown error");
        component.set("v.timesheets", timesheets);

upsertTimesheets : function(component, timesheets, callback){
    var action = component.get("c.saveTimesheets");
    timesheets.sobjectType = 'Timesheet_Unit__c';
    action.setParams({"timesheets": timesheets});
        action.setCallback(this, callback);

1 Answer 1


Managed to get this working using JSON.stringify e.g.

action.setParams({"timesheets": JSON.stringify(timesheets)});

and then deserialising in the controller

  • Glad you got it working. I am looking forward to when they fix this and the issue with empty variables in classes sent to client. I can then clean up my code a lot
    – Eric
    Commented May 5, 2017 at 16:14
  • Thanks! This helped me as well. I had same issue then used the JSON.sringify and it worked.
    – dphil
    Commented May 17, 2017 at 15:04
  • This helped me a lot, thx. Commented Mar 27, 2018 at 14:40

You must log in to answer this question.

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