getListObjectInfo

This wire adapter gets the metadata for a list view object.

Syntax 

1import { LightningElement, wire } from "lwc";
2import { getListObjectInfo } from "lightning/uiListsApi";
3import ACCOUNT_OBJECT from "@salesforce/schema/Account";
4export default class Example extends LightningElement {
5  @wire(getListObjectInfo, { objectApiName: ACCOUNT_OBJECT })
6  propertyOrFunction;
7}

User Interface API Resource 

1GET /ui-api/list-object-info/${objectApiName}

See Get Metadata for a List View Object.

Parameters 

Parameter NameTypeDescriptionRequired?
objectApiNameStringThe API name of a supported object.Yes

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’s data property or error property.
  • If a function is decorated with @wire, the results are returned in an object with a data property and an error property.

Returns 

Usage 

This code example fetches the list object info for an object and then displays the list of columns for the object.

1<!-- wireGetListObjectInfo.html -->
2<template>
3  <lightning-card title="wireGetListObjectInfo">
4    <template lwc:if={columns}>
5      <div class="slds-m-around_medium">
6        <template for:each={columns} for:item="col">
7          <li key={col.fieldApiName}>{col.fieldApiName} : {col.label}</li>
8        </template>
9      </div>
10    </template>
11  </lightning-card>
12</template>
1// wireGetListObjectInfo.js
2import { LightningElement, wire } from "lwc";
3import { getListObjectInfo } from "lightning/uiListsApi";
4import ACCOUNT_OBJECT from "@salesforce/schema/Account";
5export default class WireListInfoByName extends LightningElement {
6  error;
7  columns;
8  @wire(getListObjectInfo, {
9    objectApiName: ACCOUNT_OBJECT.objectApiName,
10  })
11  listObjectInfo({ error, data }) {
12    if (data) {
13      this.columns = data.columns;
14      this.error = undefined;
15    } else if (error) {
16      this.error = error;
17      this.columns = undefined;
18    }
19  }
20}

See Also