Develop Secure Code
ui*Api Supported Objects
getRelatedListCount
getRelatedListInfo
getRelatedListInfoBatch
getRelatedListRecords
getRelatedListRecordsBatch
getRelatedListsInfo
getRelatedListCountUse this wire adapter to get the RelatedList record count.
1import { LightningElement, wire } from 'lwc';
2import { getRelatedListCount } from 'lightning/uiRelatedListApi';
3
4export default class LdsGetRelatedListCount extends LightningElement {
5 @wire(getRelatedListCount, {
6 parentRecordId: '001RM000003UNu6YAG',
7 relatedListId: 'Contacts',
8 })
9}1GET /ui-api/related-list-count/${parentRecordId}/${relatedListId}See Get Related List Record Count.
| Parameter Name | Type | Description | Required? |
|---|---|---|---|
parentRecordId | String | The ID of the parent record that you want to get related lists for, like an Account ID. | ![]() |
relatedListId | String | The API name of a related list object such as Contacts, Opportunities, or Cases. | ![]() |
maxCount | Number | The maximum number of records to return. The default value is 20. |
data—Related List Record Counterror—FetchResponseThis code example fetches the record count for a related list.
1<!-- wireGetRelatedListCount.html -->
2<template>
3 <lightning-card title="wireGetRelatedListCount">
4 <template lwc:if={responseData}>
5 <div class="slds-m-around_medium">
6 <p key={responseData.count}>{responseData.count} : {responseData.hasMore}</p>
7 </div>
8 </template>
9 </lightning-card>
10</template>1// wireGetRelatedListCount.js
2import { LightningElement, wire } from "lwc";
3import { getRelatedListCount } from "lightning/uiRelatedListApi";
4export default class WireGetRelatedListCount extends LightningElement {
5 error;
6 responseData;
7 @wire(getRelatedListCount, {
8 parentRecordId: "001RM000003UNu6YAG",
9 relatedListId: "Contacts",
10 })
11 listInfo({ error, data }) {
12 if (data) {
13 this.responseData = data;
14 this.error = undefined;
15 } else if (error) {
16 this.error = error;
17 this.responseData = undefined;
18 }
19 }
20}See Also