Develop Secure Code
ui*Api Supported Objects
createListInfo
deleteListInfo
getListInfoByName
getListInfosByName
getListInfosByObjectName
getListObjectInfo
getListPreferences
getListRecordsByName
updateListInfoByName
updateListPreferences
updateListPreferencesUse this wire adapter to update the preferences for a list view.
1import { updateListPreferences } from "lightning/uiListsApi";
2import ACCOUNT_OBJECT from "@salesforce/schema/Account";
3
4export default class UpdateListPrefExample extends LightningElement {
5
6 updateListPreferences({
7 objectApiName: ACCOUNT_OBJECT,
8 listViewApiName: "AllAccounts",
9 });
10}1PATCH /ui-api/list-preferences/${objectApiName}/${listViewApiName}See Update List View Preferences.
| 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. | ![]() |
columnWidths | Object | The column-width preferences for the list. Pass in a key-value pair with the name of the column and an integer. | |
columnWrap | Object | The column-wrapping preferences for the list. Pass in a key-value pair with the name of the column and a boolean. | |
listReference | Object | The reference information for the list. | |
orderedBy | String[] | The ordering preference for the list. Type List Order Input[]. |
data—List Infoerror–FetchResponseThis code example updates a list view’s preferences and displays the updated values.
1<!-- wireUpdateListPreferences.html -->
2<template>
3 <lightning-card title="wireUpdateListPreferences">
4 <lightning-button variant="brand" label="Update List View Preferences" title="Primary action" onclick={updateListViewPrefs} class="slds-m-left_x-small"></lightning-button>
5 <template lwc:if={columnWidths}>
6 <div class="slds-m-around_medium">
7 <template for:each={columnWidths} for:item="col">
8 <li key={col}>{col}</li>
9 </template>
10 </div>
11 </template>
12 </lightning-card>
13</template>1// wireUpdateListPreferences.js
2import { updateListPreferences } from "lightning/uiListsApi";
3import { LightningElement, api } from "lwc";
4import ACCOUNT_OBJECT from "@salesforce/schema/Account";
5export default class UpdateListPrefs extends LightningElement {
6 error;
7 columnWidths;
8 @api async updateListViewPrefs() {
9 updateListPreferences({
10 objectApiName: ACCOUNT_OBJECT.objectApiName,
11 listViewApiName: "AllAccounts",
12 columnWidths: {
13 Type: 200,
14 "Owner.Alias": 200,
15 Phone: 200,
16 BillingState: 250,
17 Name: 250,
18 },
19 })
20 .then((result) => {
21 this.columnWidths = Object.entries(result.data.columnWidths);
22 })
23 .catch((error) => {
24 this.error = error;
25 });
26 }
27}See Also