I am creating a code that is supposed to Saved data given by the user, however the data that I pass to apex is null, I cannot get why.

here is my js:

        this.toggleSaveLabel = 'Saving...'
        this.updatedData['Id'] = this.recordData.Id
        UW_SavedData({records : this.updatedData}).then(() => {
            console.log('then trigered')
            this.toggleSaveLabel = 'Saved';
                new ShowToastEvent({
                    title : 'Success',
                    message : `Records saved succesfully!`,
                    variant : 'success',
            this.isEdited = false;
            this.error = undefined;
        .catch(error => {
            this.error = error;
            this.record = undefined;
            //console.log("Error in Save call back:", this.error);
        .finally(() => {
            setTimeout(() => {
                this.toggleSaveLabel = 'Save';
            }, 3000);


here for example in my console.log(this.updatedData), it prints to my console: {UW_occupency_rate__c: "45", Id: "00Q2600000DVMLeEAP"}

my apex looks like that:

public static void UW_SavedData(Lead records){
    if(records != null){
        string currentId = records.Id;
        Lead Prop = [SELECT Id, UW_occupency_rate__c, UW_otherRevenue__c, UW_roomCostOfSales__c, UW_OtherCostOfSales__c,
                            UW_OperatingCost__c, UW_LabourAndBenefitCost__c, UW_taxCost__c, UW_MaxRent__c
                            FROM Lead WHERE Id = :currentId];   
        //Prop.UW_occupency_rate__c = record.UW_occupency_rate__c;
        //Prop.UW_otherRevenue__c = record.UW_otherRevenue__c;
        //Prop.UW_roomCostOfSales__c = record.UW_roomCostOfSales__c;
        //Prop.UW_OtherCostOfSales__c = record.UW_OtherCostOfSales__c;
        //Prop.UW_OperatingCost__c = record.UW_OperatingCost__c;
        //Prop.UW_LabourAndBenefitCost__c = record.UW_LabourAndBenefitCost__c;
        //Prop.UW_taxCost__c = record.UW_taxCost__c;
        //Prop.UW_MaxRent__c = record.UW_MaxRent__c;
        //update Prop;

and here my system debug print my test ==> so the apex class is triggered but system.debug(records) return Null

What am I doing wrong ? I should be able to see my data .. thx you

1 Answer 1


Based on this blog you need to either pass the object to the apex as object and not as sobject, or you need to add the {'sobjectType':'Contact'}.

You must log in to answer this question.

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