Chaining Wire API calls LWC SalesForce
1 min readJun 8, 2020
You can indirectly chain your wire calls in LWC using the $ operator in the input param of the call
First call -
@wire(getRecord, {recordId: '$recordId', fields: FIELDS1})
GetParentRecordId({error, data}) {
if (data) {
this.parentId = data.fields.ObjectApiName1.value;
} else if (error) {
console.log('error2 ', error)
}
}
Second Call -
@wire(getRecord, {recordId: '$parentId', fields: FIELDS2})
GetGrandParentRecordId({error, data}) {
if (data) {
this.GrandParentId = data.fields.ObjectApiName2.value;
} else if (error) {
console.log('error2 ', error)
}
}