Search.../

deleteLabel( )

Developer Preview

Deletes a label from the site and removes it from contacts it applies to.

Description

The deleteLabel() function returns a Promise that resolves when the specified label is deleted.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function deleteLabel(key: string): Promise<void>

deleteLabel Parameters

NAME
TYPE
DESCRIPTION
key
string

Label key to delete.

Returns

Return Type:

Promise<
void
>

Was this helpful?

Delete a label (dashboard page code)

Copy Code
1import { labels } from 'wix-crm.v2';
2
3/* Sample key value: 'custom.at-risk' */
4
5export async function myDeleteLabelFunction(key) {
6
7 try {
8 const deletedLabel = await labels.deleteLabel(key);
9 console.log('Label deleted.');
10
11 } catch (error) {
12 console.log(error);
13 // Handle the error
14 }
15}
16
17/* Promise resolves to void */
Delete a label (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { labels } from 'wix-crm.v2';
3import { elevate } from 'wix-auth';
4
5/* Sample key value: 'custom.at-risk' */
6
7export const myDeleteLabelFunction = webMethod(Permissions.Anyone, async (key) => {
8 try {
9 const elevatedDeleteLabel = elevate(labels.deleteLabel);
10 const deletedLabel = await elevatedDeleteLabel(key);
11 console.log('Label deleted.');
12 } catch (error) {
13 console.log(error);
14 // Handle the error
15 }
16});
17
18/* Promise resolves to void */