getRelatedListsInfo

Use this wire adapter to get the metadata for RelatedLists in an object’s default layout.

Syntax 

1import { LightningElement, api, wire, track } from 'lwc';
2import { getRelatedListsInfo } from 'lightning/uiRelatedListApi';
3import ACCOUNT_OBJECT from '@salesforce/schema/Account';
4
5export default class LdsGetRelatedListsInfo extends LightningElement {
6  @wire(getRelatedListsInfo, {
7    parentObjectApiName: ACCOUNT_OBJECT.objectApiName,
8    recordTypeId: '012000000000000AAA'// optional
9  })
10}

User Interface API Resource 

1GET /ui-api/related-list-info/${parentObjectApiName}

See Get Related Lists Info.

Parameters 

Parameter NameTypeDescriptionRequired?
parentObjectApiNameStringThe API name of a parent object that you want to get related lists for, like an Account.Yes
recordTypeIdStringThe ID of the parent record type.

Returns 

Usage 

This code example fetches the related lists info by API name of the parent object, then iterates through the related lists.

1<!-- wireGetRelatedListsInfo.html -->
2<template>
3  <lightning-card title="wireGetRelatedListsInfo">
4    <template lwc:if={relatedLists}>
5      <div class="slds-m-around_medium">
6        <template for:each={relatedLists} for:item="relatedList">
7          <p key={relatedList.label}>{relatedList.label}</p>
8        </template>
9      </div>
10    </template>
11  </lightning-card>
12</template>
1// wireGetRelatedListsInfo.js
2import { LightningElement, wire } from "lwc";
3import { getRelatedListsInfo } from "lightning/uiRelatedListApi";
4import ACCOUNT_OBJECT from "@salesforce/schema/Account";
5
6export default class WireGetRelatedListsInfo extends LightningElement {
7  error;
8  relatedLists;
9  @wire(getRelatedListsInfo, {
10    parentObjectApiName: ACCOUNT_OBJECT.objectApiName,
11    recordTypeId: "012000000000000AAA", //optional
12  })
13  listInfo({ error, data }) {
14    if (data) {
15      this.relatedLists = data.relatedLists;
16      this.error = undefined;
17    } else if (error) {
18      this.error = error;
19      this.relatedLists = undefined;
20    }
21  }
22}

See Also