I have 2 methods in my apex class one is fetching the record and another one is for updating
public with sharing class UpdateCaseRecord {
@AuraEnabled(cacheable=true)
public static Case fetchCase(Id caseId){
return [SELECT Id,EngineeringReqNumber__c FROM Case where id=:caseId];
}
@AuraEnabled
public static void updateCase(Case con, Id recTypId){
System.debug(con);
system.debug('============>'+recTypId);
update con;
}
}
So
I have to pass 2 independent record Id to both the method. As you can see in updateCase
method I am passing recTypId
which I decorated in @wire
but its giving me null value
import getCaseRec from "@salesforce/apex/UpdateCaseRecord.fetchCase";
import updateCaseRecord from '@salesforce/apex/UpdateCaseRecord.updateCase';
@api selectedValue;
@api recordId;
@wire (getCaseRec , { caseId: '$recordId'})
fetchCase( resp){
this.wiredCase = resp;
this.realFormData = {... this.wiredCase.data};
}
@wire (updateCaseRecord , { recTypId: '$selectedValue'})
saveRecord(event){
updateCaseRecord({con : this.realFormData}).then(()=>{
console.log('Refresh Apex called');
refreshApex(this.wiredCase);
});
}
Note
In above code @api selectedValue;
contains the Id
of RecordTypes, It will pass the dynamic id value of that RecordType based upon the value selected from the dropdown