This wire adapter gets the metadata for a list view object.
Syntax
import { LightningElement, wire } from "lwc";
import { getListObjectInfo } from "lightning/uiListsApi";
import ACCOUNT_OBJECT from "@salesforce/schema/Account";
export default class Example extends LightningElement {
@wire(getListObjectInfo, { objectApiName: ACCOUNT_OBJECT })
propertyOrFunction;
}
User Interface API Resource
GET /ui-api/list-object-info/${objectApiName}
See Get Metadata for a List View Object.
Parameters
| Parameter Name | Type | Description | Required? |
|---|---|---|---|
objectApiName |
String | The API name of a supported object. | ![]() |
Read the data that's returned by the wire adapter using a property or function.
propertyOrFunction—A private property or function that receives the stream of data from the wire service.
- If a property is decorated with
@wire, the results are returned to the property’sdataproperty orerrorproperty. - If a function is decorated with
@wire, the results are returned in an object with adataproperty and anerrorproperty.
Returns
data–List Object Infoerror–FetchResponse
Usage
This code example fetches the list object info for an object and then displays the list of columns for the object.
<!-- prettier-ignore --><!-- wireGetListObjectInfo.html -->
<template>
<lightning-card title="wireGetListObjectInfo">
<template lwc:if={columns}>
<div class="slds-m-around_medium">
<template for:each={columns} for:item="col">
<li key={col.fieldApiName}>{col.fieldApiName} : {col.label}</li>
</template>
</div>
</template>
</lightning-card>
</template>
// wireGetListObjectInfo.js
import { LightningElement, wire } from "lwc";
import { getListObjectInfo } from "lightning/uiListsApi";
import ACCOUNT_OBJECT from "@salesforce/schema/Account";
export default class WireListInfoByName extends LightningElement {
error;
columns;
@wire(getListObjectInfo, {
objectApiName: ACCOUNT_OBJECT.objectApiName,
})
listObjectInfo({ error, data }) {
if (data) {
this.columns = data.columns;
this.error = undefined;
} else if (error) {
this.error = error;
this.columns = undefined;
}
}
}
See Also
