Renames a label.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function renameLabel(
key: string,
label: RenameLabel,
options: RenameLabelOptions,
): Promise<ContactLabel>;
Label key.
key
is generated when the label is created.
It can't be modified, even if displayName
is updated.
Label to rename.
Language options.
import { labels } from "wix-crm.v2";
/* Sample key value:
*
* 'custom.active-customer'
*
* Sample label object:
* {
* displayName: "Customer"
* }
*/
export async function myRenameLabelFunction(key, label) {
try {
const renamedLabel = await labels.renameLabel(key, label);
console.log("successfully renamed label:", renamedLabel);
return renamedLabel;
} catch (error) {
console.log(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "namespace": "custom",
* "namespaceDisplayName": "Labels",
* "key": "custom.active-customer",
* "displayName": "Customer",
* "labelType": "USER_DEFINED",
* "legacyId": "74f1e5c6-d9d5-4485-b272-13081ea35f38",
* "_createdDate": "2023-12-25T06:13:21.000Z",
* "_updatedDate": "2023-12-25T09:14:37.000Z"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.