Develop Secure Code
ui*Api Supported Objects
createListInfo
deleteListInfo
getListInfoByName
getListInfosByName
getListInfosByObjectName
getListObjectInfo
getListPreferences
getListRecordsByName
updateListInfoByName
updateListPreferences
createListInfoUse this wire adapter to create a list view associated with a supported object.
1import { createListInfo } from "lightning/uiListsApi";
2import ACCOUNT_OBJECT from "@salesforce/schema/Account";
3
4createListInfo({ objectApiName: ACCOUNT_OBJECT, listViewApiName: "MyAccountListView" });1POST /ui-api/list-info/${objectApiName}See Create a List View for an Object.
| Parameter Name | Type | Description | Required? |
|---|---|---|---|
objectApiName | String | The API name of a supported object. | ![]() |
listViewApiName | String | The API name of a list view, such as AllAccounts. | ![]() |
displayColumns | String[] | Display columns (field API names) for the list. | |
filterLogicString | String | The filter logic string, such as (1 OR 2) and 3. Indexes start with 1. | |
filteredByInfo | Object | Filtering information for the list. Type List Filter By Info Input. | |
label | String | The list’s display label, such as All Accounts. | |
listShares | String[] | Objects that the list is shared with, if visibility is Shared. | |
scope | Object | Scope information for the list. See List Scope Input. | |
visibility | String | The list’s level of visibility. Valid values are: Private, Public, Shared. |
data—List Infoerror–FetchResponseThis code example creates a new list view on the button click.
1<!-- wireCreateListInfo.html -->
2<template>
3 <lightning-card title="wireCreateListInfo">
4 <lightning-button variant="brand" label="Create new List View" title="Primary action" onclick={createListView} class="slds-m-left_x-small"></lightning-button>
5 <template lwc:if={displayColumns}>
6 <div class="slds-m-around_medium">
7 New list View display columns:
8 <template title="thing" for:each={displayColumns} for:item="col">
9 <p key={col.fieldApiName}>{col.fieldApiName} : {col.label}</p>
10 </template>
11 </div>
12 </template>
13 </lightning-card>
14</template>1// wireCreateListInfo.js
2import { createListInfo } from "lightning/uiListsApi";
3import { LightningElement, api } from "lwc";
4import ACCOUNT_OBJECT from "@salesforce/schema/Account";
5export default class CreateListInfo extends LightningElement {
6 error;
7 displayColumns;
8 @api async createListView() {
9 createListInfo({
10 objectApiName: ACCOUNT_OBJECT.objectApiName,
11 listViewApiName: "AllAccounts_createListInfoTest",
12 })
13 .then((result) => {
14 this.displayColumns = result.data.displayColumns;
15 })
16 .catch((error) => {
17 this.error = error;
18 });
19 }
20}See Also