# How can developers utilize lightning/uiListApi to fetch and display standard list view data?

**Topic:** LWC · **Difficulty:** Medium · **Tags:** LWC, uiListApi, List Views

Read it on the site: https://www.forcechallenges.com/interview-questions/how-can-developers-utilize-lightning-uilistapi-to-fetch-and-display-standard-list-view-data

## Answer

**Basics:** List views already encode filters, columns and sort order. Instead of re-implementing them in SOQL, you can read them: `getListInfoByName({ objectApiName, listViewApiName })` returns metadata (display columns, filter info), and `getListRecordsByName` or `getListUi` return the records. Use it for components that show "my open cases" exactly as a list view does.

**How it works:** Wire the adapter with `objectApiName` and `listViewApiName` (or `listViewId`) plus options such as `pageSize` (default 50), `sortBy` (field names, `-` prefix for descending), `fields`/`optionalFields` (for `getListRecordsByName`) and `pageToken`. Results contain `records.records[i].fields.Name.value`; `nextPageToken` is used for paging. Because the structure is nested, flatten rows before binding to `lightning-datatable`.

**Advanced / deep dive:** `getListUi` returns both metadata and records, and is the older adapter; the newer pair `getListInfoByName` plus `getListRecordsByName` separates concerns and allows requesting extra fields (verify which are preferred in the current docs, as older adapters may be marked for replacement). Results respect the user's sharing, FLS and the list view's visibility, so different users see different rows. Use `lightning/uiObjectInfoApi` `getObjectInfo` for column labels and types. Paging uses tokens, not offsets, so you cannot jump to arbitrary pages. For complex joins, aggregates or beyond 2,000 rows per page, use Apex SOQL. List views using unsupported filters (for example some cross-object filters) or objects not supported by UI API will not load. The data is cached by LDS, so refresh after DML with the notify APIs.

**Code / config example:**
```javascript
import { LightningElement, wire } from 'lwc';
import { getListUi } from 'lightning/uiListApi';
import ACCOUNT from '@salesforce/schema/Account';

export default class ListViewTable extends LightningElement {
    rows = [];
    columns = [{ label: 'Name', fieldName: 'Name' }, { label: 'Industry', fieldName: 'Industry' }];

    @wire(getListUi, { objectApiName: ACCOUNT, listViewApiName: 'AllAccounts', pageSize: 25 })
    wired({ data, error }) {
        if (data) {
            this.rows = data.records.records.map(r => ({
                Id: r.id,
                Name: r.fields.Name.value,
                Industry: r.fields.Industry.value
            }));
        }
    }
}
```

**Hidden gotchas & must-remember points:**
- Record data is nested under `fields.<Field>.value`; flatten for datatables.
- `listViewApiName` is the list view's API name, not its label.
- Paging is token-based.
- Results depend on the current user's sharing and list view access.
- Some list views and objects are not supported by UI API.
- Fields shown depend on the list view's columns unless you request more.

**Best practice:** Use it when you must mirror an existing list view, and use Apex when you need custom queries or aggregates.

---
Source: ForceChallenges · last updated 2026-11-02
