getRelatedListRecords
You can utilize this wire adapter to access RelatedList records. Related lists present information and links to records linked with a particular record. For instance, an account might have related lists for contacts, cases, notes, or files.
Demo Code:
import { LightningElement, wire, api } from 'lwc';
import { getRelatedListRecords } from 'lightning/uiRelatedListApi';
export default class Acc extends LightningElement {
error;
records;
@wire(getRelatedListRecords, {
parentRecordId: '0015g00000DMcjgAAD',
relatedListId: 'Contacts',
fields: ['Contact.Name','Contact.Id'],
sortBy: ['Contact.Name']
})
listInfo({ error, data }) {
if (data) {
this.records = data.records;
console.log('test Dataa ', this.records);
this.error = undefined;
} else if (error) {
this.error = error;
this.records = undefined;
}
}
}
Parameters
parentRecordId
—(Required) The ID of the parent record that you want to get related lists for, like an Account ID.relatedListId
—(Required) The API name of a related list object, like Contacts, Opportunities, or Cases.fields
—(Optional) The API names of the related list’s column fields.optionalFields
—(Optional) The API names of additional fields in the related list.pageSize
—(Optional) The number of list records to return per page.sortBy
—(Optional) An array of field API names to sort the related list by. Accepts only one value per request.where
—(Optional) The filter to apply to related list records.
Demo:
Comments
Post a Comment
Please Write your comment here.