+ Start a Discussion
Sarita Pa 3Sarita Pa 3 

Lightning web component Wiring.

Hi Team,

Can it be possible to call wired method in another wired method.
Sporadically the name value is being sent to Apex class empty, i am thinking this might be because of the order of invoking the wired is not coming before the getrecord. Is there any way to call one wired function in another wired method.

Attaching the sample code.
Thanks for your help with this.
Thanks and Regards,
Venkata.

import {getRecord} from 'lightning/uiRecordAPi';
import dataBasedonName from 'apex/class/test.getName;

@track name;
@api recordId;
@wire (getRecord,{recordId:$recordId,fields:['Name']}
wiredInfo({data}){
   if (data)
{
  this.name=data.fields.name;
}
}

@wire (dataBasedonName,{name:$name})
wiredNameList({data}){
if(data){

}
}
karthikeyan perumalkarthikeyan perumal
Hello, 

Use below code. 
import {getRecord} from 'lightning/uiRecordAPi';
import dataBasedonName from 'apex/class/test.getName;

@track name;
@api recordId;
@wire (getRecord,{recordId:$recordId,fields:['Name']})
RecordInfo;

@wire (dataBasedonName,{name:$RecordInfo.data.fields.name})
wiredNameList({data}){
if(data){

}
}
Now the first wire funnction will get the values of RecordInfo, then the  second one will be excuted. 
hope this will wwork for you. 

Thanks

karthik

 
Sarita Pa 3Sarita Pa 3
Hi Karthik,
Thank you for the reply I am getting the same issue again.