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:
handleSave(){
console.log("Saving...")
this.toggleSaveLabel = 'Saving...'
this.updatedData['Id'] = this.recordData.Id
console.log(this.updatedData)
UW_SavedData({records : this.updatedData}).then(() => {
console.log('then trigered')
this.toggleSaveLabel = 'Saved';
this.dispatchEvent(
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:
@AuraEnabled
public static void UW_SavedData(Lead records){
system.debug('test');
system.debug(records);
if(records != null){
system.debug(records);
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