function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abhishek VinodAbhishek Vinod 

save the values to the custom object

I need to save the values to the custom object. But when I upsert I get error that it is a null list.
My controller:
CreateExpense: function(component, event, helper) {
         
            alert("Hi");
       var Expense=component.get("v.Expense");
        component.set("v.Expense",Expense);
alert(Expense);   
      helper.CreateExpense(component,Expense);
    }
Helper:
({
    CreateExpense : function(component,expenses){         
        alert("upsert");       
       this.upsertExpense(component, expenses, function(a) {
           var exp = component.get("v.exp");
           exp.push(a.getReturnValue());
            component.set("v.exp", exp);
            });
    },
         upsertExpense : function(component, expenses, callback) {
           var action = component.get("c.saveexp");
        action.setParams({ 
            "expense":expenses
            
        });
     if (callback) {
action.setCallback(this, callback);
     }
  
$A.enqueueAction(action);
}      
    
})
Apex controller:
Public with sharing class ExpenseController {
     @AuraEnabled
    public static expense__c saveexp(expense__c expenses)
    { 
        
       upsert expenses;
        system.debug('@@@@@@@@@@@@'+expenses);
        return expenses;
    }

}
Thanks
NickDzitarsNickDzitars
You cannot pass complex object parameters to your apex functions. Passing a full expense object is unfortunately out of the question until Salesforce fixes that. I'd recommend taking a look at the following post for a more detailed explanation and a possible workaround.

https://developer.salesforce.com/forums/?id=906F00000005GiwIAE