Skip to content

Instantly share code, notes, and snippets.

@arun12209
Last active June 5, 2022 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arun12209/9ebe0534924e27f236cb3fa074431253 to your computer and use it in GitHub Desktop.
Save arun12209/9ebe0534924e27f236cb3fa074431253 to your computer and use it in GitHub Desktop.
import { LightningElement,wire,api} from 'lwc';
import { getRelatedListRecords } from 'lightning/uiRelatedListApi';
export default class GetRelatedListRecords extends LightningElement {
@api recordId;
error;
records;
//get all contacts records of Account
@wire(getRelatedListRecords, {
parentRecordId: '$recordId',
relatedListId: 'Contacts',
fields: ['Contact.Name','Contact.Id']
}) contacts({ error, data }){
if (data) {
this.records = data.records;
console.log('data: '+JSON.stringify(data));
this.error = undefined;
} else if (error) {
this.error = error;
this.records = undefined;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment