deleteListInfo

Use this wire adapter to delete a list view.

Syntax 

1import { deleteListInfo } from "lightning/uiListsApi";
2import ACCOUNT_OBJECT from "@salesforce/schema/Account";
3
4deleteListInfo({ objectApiName: ACCOUNT_OBJECT, listViewApiName: "MyAccountListView" });

User Interface API Resource 

1DELETE /ui-api/list-info/${objectApiName}/${listviewApiName}

See Delete List View Metadata.

Parameters 

Parameter NameTypeDescriptionRequired?
objectApiNameStringThe API name of a supported object.Yes
listViewApiNameStringThe API name of a list view, such as AllAccounts.Yes

Returns 

If a list view is deleted successfully, there’s no response.

Usage 

This code example deletes a list view when the button is clicked.

1<!-- wireDeletListInfo.html -->
2<template>
3   <lightning-card title="wireDeleteListInfo">
4       <lightning-button variant="brand" label="Delete List View" title="Primary action" onclick={deleteListView} class="slds-m-left_x-small"></lightning-button>
5       <template lwc:if={deleted}>
6           <p>List View Deleted</p>
7       </template>
8       <template lwc:if={errorMessage}>
9           <p>{errorMessage}</p>
10       </template>
11
12   </lightning-card>
13</template>
1// wireDeleteListInfo.js
2import { deleteListInfo } from "lightning/uiListsApi";
3import { LightningElement, api } from "lwc";
4import ACCOUNT_OBJECT from "@salesforce/schema/Account";
5export default class DeleteListInfo extends LightningElement {
6  errorMessage;
7  deleted;
8  @api async deleteListView() {
9    deleteListInfo({
10      objectApiName: ACCOUNT_OBJECT.objectApiName,
11      listViewApiName: "AllAccounts_deleteListInfoTest",
12    })
13      .then(() => {
14        this.deleted = true;
15        this.errorMessage = undefined;
16      })
17      .catch((error) => {
18        this.errorMessage = error.body.message;
19        this.deleted = undefined;
20      });
21  }
22}

See Also