updateListPreferences

Use this wire adapter to update the preferences for a list view.

Syntax 

import { updateListPreferences } from "lightning/uiListsApi";
import ACCOUNT_OBJECT from "@salesforce/schema/Account";

export default class UpdateListPrefExample extends LightningElement {

  updateListPreferences({
    objectApiName: ACCOUNT_OBJECT,
    listViewApiName: "AllAccounts",
  });
}

User Interface API Resource 

PATCH /ui-api/list-preferences/${objectApiName}/${listViewApiName}

See Update List View Preferences.

Parameters 

Parameter NameTypeDescriptionRequired?
objectApiNameStringThe API name of a supported object.Yes
listViewApiNameStringThe API name of a list view, such as AllAccounts.Yes
columnWidthsObjectThe column-width preferences for the list. Pass in a key-value pair with the name of the column and an integer.
columnWrapObjectThe column-wrapping preferences for the list. Pass in a key-value pair with the name of the column and a boolean.
listReferenceObjectThe reference information for the list.
orderedByString[]The ordering preference for the list. Type List Order Input[].

Returns 

Usage 

This code example updates a list view’s preferences and displays the updated values.

<!-- wireUpdateListPreferences.html -->
<template>
   <lightning-card title="wireUpdateListPreferences">
       <lightning-button variant="brand" label="Update List View Preferences" title="Primary action" onclick={updateListViewPrefs} class="slds-m-left_x-small"></lightning-button>
       <template lwc:if={columnWidths}>
           <div class="slds-m-around_medium">
               <template for:each={columnWidths} for:item="col">
                   <li key={col}>{col}</li>
               </template>
           </div>
       </template>
   </lightning-card>
</template>
// wireUpdateListPreferences.js
import { updateListPreferences } from "lightning/uiListsApi";
import { LightningElement, api } from "lwc";
import ACCOUNT_OBJECT from "@salesforce/schema/Account";
export default class UpdateListPrefs extends LightningElement {
  error;
  columnWidths;
  @api async updateListViewPrefs() {
    updateListPreferences({
      objectApiName: ACCOUNT_OBJECT.objectApiName,
      listViewApiName: "AllAccounts",
      columnWidths: {
        Type: 200,
        "Owner.Alias": 200,
        Phone: 200,
        BillingState: 250,
        Name: 250,
      },
    })
      .then((result) => {
        this.columnWidths = Object.entries(result.data.columnWidths);
      })
      .catch((error) => {
        this.error = error;
      });
  }
}

See Also

The Summer '25 guide is now live

Looking for the Component Reference? Go to https://developer.salesforce.com/docs/component-library/.