getRelatedListsInfo
Use this wire adapter to get the metadata for RelatedLists in
an object’s default layout.
Parameters
- parentObjectApiName—(Required) The API name of a parent object that
you want to get related lists for, like an Account.
- recordTypeId—(Optional) The ID of the parent record type.
HTML
<template>
<lightning-card title="Related List of Account">
<template if:true={relatedLists}>
<div class="slds-m-around_medium">
<template for:each={relatedLists} for:item="relatedList">
<p key={relatedList.label}>
{relatedList.label}
</p>
</template>
</div>
</template>
</lightning-card>
</template>
JS
import { LightningElement,wire} from 'lwc';
import { getRelatedListsInfo } from 'lightning/uiRelatedListApi';
export default class GetRelatedListDetails extends LightningElement {
error;
relatedLists;
@wire(getRelatedListsInfo, {
parentObjectApiName: 'Account',
})listInfo({ error, data }) {
if (data) {
this.relatedLists = data.relatedLists;
this.error = undefined;
} else if (error) {
this.error = error;
this.relatedLists = undefined;
}
}
}
XML
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>54.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__RecordPage</target>
</targets>
</LightningComponentBundle>
RESULT:
No comments:
Post a Comment