getListInfosByObjectName

Use this wire to get the list views associated with a supported object.

Syntax 

1import { LightningElement, wire } from "lwc";
2import { getListInfosByObjectName } from "lightning/uiListsApi";
3import ACCOUNT_OBJECT from "@salesforce/schema/Account";
4
5export default class Example extends LightningElement {
6  @wire(getListInfosByObjectName, {
7    objectApiName: ACCOUNT_OBJECT,
8    pageSize: 10,
9    recentListsOnly: true,
10  })
11  propertyOrFunction;
12}

User Interface API Resource 

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

See Get List Views for an Object.

Parameters 

Parameter NameTypeDescriptionRequired?
objectApiNameStringThe API name of a supported object.Yes
pageSizeNumberThe number of list records viewed at one time. The default value is 20. Valid values are 1–2000.
pageTokenNumberA token that represents the page offset. To indicate where the page starts, use this value with the pageSize parameter. The maximum offset is 2000, and the default is 0.
qStringA search term to filter the results. Wildcards are supported.
recentListsOnlyBooleanIndicates whether to get recent lists only (true) or not (false). The default is false.

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 of list views for an object and displays the list view labels.

1<!-- wireGetListInfosByObjectName.html -->
2<template>
3   <lightning-card title="wireGetListInfosByObjectName">
4       <template lwc:if={lists}>
5           <div class="slds-m-around_medium">
6               <template for:each={lists} for:item="list">
7                   <li key={list.label}>{list.label}</li>
8               </template>
9           </div>
10       </template>
11   </lightning-card>
12</template>
1// wireGetListInfosByObjectName.js
2import { LightningElement, wire } from "lwc";
3import { getListInfosByObjectName } from "lightning/uiListsApi";
4import ACCOUNT_OBJECT from "@salesforce/schema/Account";
5
6export default class GetListOfLists extends LightningElement {
7  error;
8  lists;
9  @wire(getListInfosByObjectName, {
10    objectApiName: ACCOUNT_OBJECT.objectApiName,
11    pageSize: 10,
12  })
13  listOfLists({ error, data }) {
14    if (data) {
15      this.lists = data.lists;
16      this.error = undefined;
17      debugger;
18    } else if (error) {
19      this.error = error;
20      this.lists = undefined;
21      debugger;
22    }
23  }
24}

See Also

Release Preview

This release is in preview. Features described here don't become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can't guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.