getListUi (Deprecated)

Use this wire adapter to get the records and metadata for a list view.

As a deprecated feature, getListUi no longer updates and isn’t part of the “Services” under your Main Services Agreement with Salesforce. Use this feature at your sole discretion, and make your purchase decisions only on the basis of generally available products and features. Salesforce doesn’t guarantee general availability of this feature within any particular time frame or at all, and we can discontinue it at any time. getListUi is for evaluation purposes only, not for production use. It’s offered as is and isn’t supported, and Salesforce has no liability for any harm or damage arising out of or in connection with it. All restrictions, Salesforce reservation of rights, obligations concerning the Services, and terms for related Non-Salesforce Applications and Content apply equally to your use of this feature.

Note

Get list view records and metadata for a list view by API name 

Use the getListInfoByName wire adapter.

Note

Syntax 

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

User Interface API Resource 

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

See Get List View Records and Metadata.

Parameters 

  • objectApiName—(Required) The API name of a supported object.
  • listViewApiName—(Required) The API name of a list view, such as AllAccounts.

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.

You can also pass the parameters listed in this Request Parameters table. See an example in the Usage section.

Returns 

The records that are returned contain the fields specified by:

  • The list view metadata, specified by data.info.displayColumns.

  • The fields and optionalFields parameters.

    The underlying list view is controlled by the administrator so it may change. If a component requires fields, request them in the fields parameter. Don’t assume that specific fields will be returned unless you explicitly request them. If you’re not sure whether the context user has access to a field and you don’t want the request to fail if they don’t, use the optionalFields parameter.

  • The object’s system fields, if the object has them, such as CreatedDate, Id, LastModifiedById, LastModifiedDate, and SystemModstamp.

Usage 

When iterating through the previous or next set of data, consider these guidelines:

  • Use the nextPageToken and previousPageToken values.
  • You can’t use pageToken values across sessions or across page refreshes. Persisting and reusing page tokens across page refreshes isn’t guaranteed to work.

This example displays 10 contact names from a list view and lets users click through the previous and next set of data.

1<!-- wireListViewToken.html -->
2<template>
3  <lightning-card title="WireListViewToken">
4    <template lwc:if={records}>
5      <div class="slds-m-around_medium">
6        <template for:each={records} for:item="record">
7          <p key={record.fields.Id.value}>{record.fields.Name.value}</p>
8        </template>
9      </div>
10    </template>
11    <div class="slds-grid">
12      <div class="slds-m-around_medium">
13        <lightning-button label="Previous" onclick={handlePreviousPage}></lightning-button>
14      </div>
15      <div class="slds-m-around_medium slds-col_bump-left">
16        <lightning-button label="Next" onclick={handleNextPage}></lightning-button>
17      </div>
18    </div>
19  </lightning-card>
20</template>

When a user clicks the Previous and Next buttons, the pageToken parameter is updated to the previousPageToken and nextPageToken values from the data the wire service provisioned. Because pageToken is prepended with $, when its value changes the wire service provisions new data.

1// wireListViewToken.js
2import { LightningElement, wire } from "lwc";
3import { getListUi } from "lightning/uiListApi";
4
5import CONTACT_OBJECT from "@salesforce/schema/Contact";
6import NAME_FIELD from "@salesforce/schema/Contact.Name";
7
8export default class WireListViewToken extends LightningElement {
9  pageToken = null;
10  nextPageToken = null;
11  previousPageToken = null;
12  records;
13  error;
14
15  @wire(getListUi, {
16    objectApiName: CONTACT_OBJECT,
17    listViewApiName: "All_Recipes_Contacts",
18    sortBy: NAME_FIELD,
19    pageSize: 10,
20    pageToken: "$pageToken",
21  })
22  listView({ error, data }) {
23    if (data) {
24      this.records = data.records.records;
25      this.error = undefined;
26      this.nextPageToken = data.records.nextPageToken;
27      this.previousPageToken = data.records.previousPageToken;
28    } else if (error) {
29      this.error = error;
30      this.records = undefined;
31    }
32  }
33
34  handleNextPage(e) {
35    this.pageToken = this.nextPageToken;
36  }
37
38  handlePreviousPage(e) {
39    this.pageToken = this.previousPageToken;
40  }
41}

Example 

The wireListViewToken example is based on the wireListView component in the lwc-recipes GitHub repo.

Get list view records and metadata for a list view by ID 

Return list view records and metadata using the list view ID.

Syntax 

1import { LightningElement, wire } from "lwc";
2import { getListUi } from "lightning/uiListApi";
3export default class Example extends LightningElement {
4  @wire(getListUi, { listViewId: "00BT0000001TONQMA4" })
5  propertyOrFunction;
6}

User Interface API Resource 

1GET /ui-api/list-ui/${listViewId}

See Get List View Records and Metadata.

Parameters 

  • listViewId—(Required) The ID of a list view.

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.

You can also pass the parameters listed in this Request Parameters table.

Returns 

The records that are returned contain the fields specified by:

  • The list view metadata, specified by data.info.displayColumns.

  • The fields and optionalFields parameters.

    The underlying list view is controlled by the administrator so it may change. If a component requires fields, request them in the fields parameter. Don’t assume that specific fields will be returned unless you explicitly request them. If you’re not sure whether the context user has access to a field and you don’t want the request to fail if they don’t, use the optionalFields parameter.

  • The object’s system fields, if the object has them, such as CreatedDate, Id, LastModifiedById, LastModifiedDate, and SystemModstamp.

Get list view records and metadata for an MRU list view by object 

Returns record data for an object’s most recently used (MRU) list view.

Syntax 

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

User Interface API Resource 

1GET /ui-api/mru-list-records/${objectApiName}

See Get Most Recently Used List View Records.

Parameters 

  • objectApiName—(Required) The API name of a supported object.
  • listViewApiName—(Required) The API name of the MRU list view.

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.

You can also pass the parameters listed in this Request Parameters table.

Returns 

The records that are returned contain the fields specified by:

  • The list view metadata, specified by data.info.displayColumns.

  • The fields and optionalFields parameters.

    The underlying list view is controlled by the administrator so it may change. If a component requires fields, request them in the fields parameter. Don’t assume that specific fields will be returned unless you explicitly request them. If you’re not sure whether the context user has access to a field and you don’t want the request to fail if they don’t, use the optionalFields parameter.

  • The object’s system fields, if the object has them, such as CreatedDate, Id, LastModifiedById, LastModifiedDate, and SystemModstamp.

Get list views for an object 

Returns a collection of list views associated with an object.

Syntax 

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

User Interface API Resource 

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

See Get List Views for an Object.

Parameters 

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.

You can also pass the parameters listed in this Request Parameters table.

Returns 

The records that are returned contain the fields specified by:

  • The list view metadata, specified by data.info.displayColumns.

  • The fields and optionalFields parameters.

    The underlying list view is controlled by the administrator so it may change. If a component requires fields, request them in the fields parameter. Don’t assume that specific fields will be returned unless you explicitly request them. If you’re not sure whether the context user has access to a field and you don’t want the request to fail if they don’t, use the optionalFields parameter.

  • The object’s system fields, if the object has them, such as CreatedDate, Id, LastModifiedById, LastModifiedDate, and SystemModstamp.

See Also