Renames a label.
The renameLabel()
function returns a Promise
that resolves when the specified label's display name is changed.
Note:
Only visitors with
Manage Contacts permissions
can rename labels.
You can override the permissions by setting the suppressAuth
option to true
.
function renameLabel(
key: string,
displayName: string,
options: AuthOptions,
): Promise<Label>;
Label key.
key
is generated when the label is created
and cannot be modified, even if displayName
changes.
Label display name shown in the Dashboard.
Authorization options.
import { Permissions, webMethod } from "wix-web-module";
import { contacts } from "wix-crm-backend";
export const myRenameLabelFunction = webMethod(Permissions.Anyone, () => {
const labelKey = "custom.incoming-leads";
const displayName = "Incoming";
const options = {
suppressAuth: false,
};
return contacts
.renameLabel(labelKey, displayName, options)
.then((renamedLabel) => {
return renamedLabel;
})
.catch((error) => {
console.error(error);
});
});
/* Promise resolves to:
*
* {
* "_createdDate": "2021-01-19T21:38:49Z",
* "_updatedDate": "2021-01-20T19:07:54Z"
* "namespace": "custom",
* "key": "custom.incoming-leads",
* "displayName": "Incoming",
* "labelType": "USER_DEFINED"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.