Develop Secure Code
ui*Api Supported Objects
getRelatedListCount
getRelatedListInfo
getRelatedListInfoBatch
getRelatedListRecords
getRelatedListRecordsBatch
getRelatedListsInfo
getRelatedListInfoBatchUse this wire adapter to get the metadata for a batch of RelatedLists.
1import { LightningElement, wire } from 'lwc';
2import { getRelatedListInfoBatch } from 'lightning/uiRelatedListApi';
3import ACCOUNT_OBJECT from '@salesforce/schema/Account';
4
5export default class LdsGetRelatedListInfoBatch extends LightningElement {
6 @wire(getRelatedListInfoBatch, {
7 parentObjectApiName: ACCOUNT_OBJECT.objectApiName,
8 relatedListNames: ['Contacts', 'Opportunities'],
9 })
10}1GET /ui-api/related-list-info/batch/${parentObjectApiName}/${relatedListIds}See Get a Batch of Related List Metadata.
| Parameter Name | Type | Description | Required? |
|---|---|---|---|
parentObjectApiName | String | The API name of a parent object that you want to get related lists for, like an Account. | ![]() |
relatedListNames | String[] | An array of comma-separated strings that contain the API names of supported related lists for the parent object such as Contacts, Opportunities, or Cases. In the wire adapter code, relatedListNames maps to relatedListIds in the User Interface API resource. | ![]() |
recordTypeId | String | The ID of the parent record type. If not provided, the default record type is used. |
data—Simplified Batch Resultserror—FetchResponseThis code example fetches the metadata for the Contacts and Opportunities related lists in the Account object, then iterates through the list of display columns.
1<!-- wireGetRelatedListInfoBatch.html -->
2<template>
3 <template lwc:if={results}>
4 <div class="slds-m-around_medium">
5 <template for:each={results} for:item="result">
6 <lightning-card key={result.result.fieldApiName} title={result.result.label}>
7 <template for:each={result.result.displayColumns} for:item="col">
8 <p key={col.fieldApiName}>{col.label}</p>
9 </template>
10 </lightning-card>
11 </template>
12 </div>
13 </template>
14</template>1// wireGetRelatedListInfoBatch.js
2import { LightningElement, wire } from "lwc";
3import { getRelatedListInfoBatch } from "lightning/uiRelatedListApi";
4import ACCOUNT_OBJECT from "@salesforce/schema/Account";
5
6export default class WireGetRelatedListInfoBatch extends LightningElement {
7 error;
8 results;
9 @wire(getRelatedListInfoBatch, {
10 parentObjectApiName: ACCOUNT_OBJECT.objectApiName,
11 relatedListNames: ["Contacts", "Opportunities"],
12 })
13 listInfo({ error, data }) {
14 if (data) {
15 this.results = data.results;
16 this.error = undefined;
17 } else if (error) {
18 this.error = error;
19 this.results = undefined;
20 }
21 }
22}See Also