You need to sign in to do that
Don't have an account?
I am fetching recordId and passing to Apex method. But unable to get recordId in apex method.
import updateParentCase from '@salesforce/apex/UpdateMotherCase.updateParentCase';
export default class InitiateMotherCase extends LightningElement {
@api recordId;
handleClick(event){
console.log('Get the record Id is'+this.recordId);
updateParentCase({rid:'$recordId'}).then(result =>{
console.log('Get details'+result);
}).catch( error => {});
}
Apex method>>>>>
@AuraEnabled(cacheable=true)
public static void updateParentCase(String rid){
try{
System.debug('Get the case record Id details'+rid);
list<Case> c = [SELECT id,CaseNumber,ParentId,Recently_Updated__c from case where id =: rid AND ParentId != null];
System.debug('Get the case details'+c);
}
}
In your code, you are passing the value of recordId as a string literal 'recordId' instead of the actual variable value. To fix this, you need to remove the quotes around $recordId in the method call. Here's the corrected code: In the Apex method, the parameter type should be String, not void. Here's the corrected Apex method:
If this helps , please mark this as Best Answer.
Thank you.
Hello Subrat,
I am trying with above code still unable to call apex method