getLabel( )
Retrieves a label.
Description
The getLabel()
function returns a Promise
that resolves when the specified label is retrieved.
Note: Only visitors with Manage Contacts permissions can retrieve labels. You can override the permissions by setting the
suppressAuth
option totrue
.
Syntax
function getLabel(key: string, [options: AuthOptions]): Promise<Label>
getLabel Parameters
NAME
TYPE
DESCRIPTION
Label key.
key
is generated when the label is created
and cannot be modified, even if displayName
changes.
Authorization options.
Returns
Fulfilled - The specified label.
Return Type:
NAME
TYPE
DESCRIPTION
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.
Label type.
One of:
"SYSTEM"
: The label is a predefined system label for the Contact List."USER_DEFINED"
: The label was created by a site contributor or app."WIX_APP_DEFINED"
: The label was created by a Wix app.
Date and time the label was created.
Date and time the label was last updated.
Label namespace.
Labels created by site contributors or 3rd-party apps
are automatically assigned to the custom
namespace.
Was this helpful?
Get a label
1import { Permissions, webMethod } from 'wix-web-module';2import { contacts } from 'wix-crm-backend';34export const myGetLabelFunction = webMethod(Permissions.Anyone, () => {5 const labelKey = "custom.active-customer";6 const options = {7 suppressAuth: false8 };910 return contacts.getLabel(labelKey, options)11 .then((label) => {12 return label;13 })14 .catch((error) => {15 console.error(error);16 });17});1819/*20 * Promise resolves to:21 *22 * {23 * "_createdDate": "2021-01-20T00:31:41Z",24 * "_updatedDate": "2021-01-20T00:31:41Z"25 * "namespace": "custom",26 * "key": "custom.active-customer",27 * "displayName": "Active Customer",28 * "labelType": "USER_DEFINED"29 * }30 */