Search.../

renameLabel( )

Developer Preview

Renames a label.

Description

The renameLabel() function returns a Promise that resolves when the specified label's display name is changed.

Admin Method

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

Syntax

function renameLabel(key: string, label: RenameLabel, options: RenameLabelOptions): Promise<ContactLabel>

renameLabel Parameters

NAME
TYPE
DESCRIPTION
key
string

Label key.

key is generated when the label is created. It cannot be modified, even if displayName is updated.

label
RenameLabel

Label to rename.

options
Optional
RenameLabelOptions

Language options.

Returns

Return Type:

Promise<
ContactLabel
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time the label was created.

_updatedDate
Date

Date and time the label was last updated.

displayName
string

Label display name shown in the Dashboard.

key
string

Label key.

key is generated when the label is created. It cannot be modified, even if displayName is updated.

labelType
string

Label type.

  • "SYSTEM": The label is a default system label for the Contact List.
  • "USER_DEFINED": The label was created by a site contributor or 3rd-party app.
  • "WIX_APP_DEFINED": The label was created by a Wix app.
namespace
string

Label namespace.

Labels created by site admins or 3rd-party apps are automatically assigned to the custom namespace.

namespaceDisplayName
string

Display name for the namespace, used to organize the list of labels in the site Dashboard.

Was this helpful?

Rename a label (dashboard page code)

Copy Code
1import { labels } from 'wix-crm.v2';
2
3/* Sample key value:
4 *
5 * 'custom.active-customer'
6 *
7 * Sample label object:
8 * {
9 * displayName: "Customer"
10 * }
11 */
12
13export async function myRenameLabelFunction(key, label) {
14
15 try {
16 const renamedLabel = await labels.renameLabel(key, label);
17 console.log('successfully renamed label:', renamedLabel);
18
19 return renamedLabel;
20 } catch (error) {
21 console.log(error);
22 // Handle the error
23 }
24 }
25
26/* Promise resolves to:
27 * {
28 * "namespace": "custom",
29 * "namespaceDisplayName": "Labels",
30 * "key": "custom.active-customer",
31 * "displayName": "Customer",
32 * "labelType": "USER_DEFINED",
33 * "legacyId": "74f1e5c6-d9d5-4485-b272-13081ea35f38",
34 * "_createdDate": "2023-12-25T06:13:21.000Z",
35 * "_updatedDate": "2023-12-25T09:14:37.000Z"
36 * }
37 */
Rename 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:
6 *
7 * 'custom.active-customer'
8 *
9 * Sample label object:
10 * {
11 * displayName: "Customer"
12 * }
13 */
14
15export const myRenameLabelFunction = webMethod(Permissions.Anyone, async (key, label) => {
16 try {
17 const elevatedRenameLabel = elevate(labels.renameLabel);
18 const renamedLabel = await elevatedRenameLabel(key, label);
19 console.log('successfully renamed label:', renamedLabel);
20
21 return renamedLabel;
22 } catch (error) {
23 console.log(error);
24 // Handle the error
25 }
26});
27
28/* Promise resolves to:
29 * {
30 * "namespace": "custom",
31 * "namespaceDisplayName": "Labels",
32 * "key": "custom.active-customer",
33 * "displayName": "Customer",
34 * "labelType": "USER_DEFINED",
35 * "legacyId": "74f1e5c6-d9d5-4485-b272-13081ea35f38",
36 * "_createdDate": "2023-12-25T06:13:21.000Z",
37 * "_updatedDate": "2023-12-25T09:14:37.000Z"
38 * }
39 */
40