renameLabel( )
Renames a label.
Description
The renameLabel()
function returns a Promise that resolves when the specified label's display name is changed.
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
Label key.
key
is generated when the label is created.
It cannot be modified, even if displayName
is updated.
Label to rename.
Language options.
Returns
Return Type:
NAME
TYPE
DESCRIPTION
Date and time the label was created.
Date and time the label was last updated.
Label display name shown in the Dashboard.
Label key.
key
is generated when the label is created.
It cannot be modified, even if displayName
is updated.
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.
Label namespace.
Labels created by site admins or 3rd-party apps
are automatically assigned to the custom
namespace.
Display name for the namespace, used to organize the list of labels in the site Dashboard.
Was this helpful?
1import { labels } from 'wix-crm.v2';23/* Sample key value:4 *5 * 'custom.active-customer'6 *7 * Sample label object:8 * {9 * displayName: "Customer"10 * }11 */1213export async function myRenameLabelFunction(key, label) {1415 try {16 const renamedLabel = await labels.renameLabel(key, label);17 console.log('successfully renamed label:', renamedLabel);1819 return renamedLabel;20 } catch (error) {21 console.log(error);22 // Handle the error23 }24 }2526/* 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 */
1import { Permissions, webMethod } from 'wix-web-module';2import { labels } from 'wix-crm.v2';3import { elevate } from 'wix-auth';45/* Sample key value:6 *7 * 'custom.active-customer'8 *9 * Sample label object:10 * {11 * displayName: "Customer"12 * }13 */1415export 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);2021 return renamedLabel;22 } catch (error) {23 console.log(error);24 // Handle the error25 }26});2728/* 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