Search.../

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 to true.

Syntax

function getLabel(key: string, [options: AuthOptions]): Promise<Label>

getLabel Parameters

NAME
TYPE
DESCRIPTION
key
string

Label key.

key is generated when the label is created and cannot be modified, even if displayName changes.

options
Optional
AuthOptions

Authorization options.

Returns

Fulfilled - The specified label.

Return Type:

Promise<Label>
NAME
TYPE
DESCRIPTION
key
string

Label key.

key is generated when the label is created and cannot be modified, even if displayName changes.

displayName
string

Label display name shown in the Dashboard.

labelType
string

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.
_createdDate
Date

Date and time the label was created.

_updatedDate
Date

Date and time the label was last updated.

namespace
string

Label namespace.

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

Was this helpful?

Get a label

Copy Code
1import { contacts } from 'wix-crm-backend';
2
3export function myGetLabelFunction() {
4 const labelKey = "custom.active-customer";
5 const options = {
6 suppressAuth: false
7 };
8
9 return contacts.getLabel(labelKey, options)
10 .then((label) => {
11 return label;
12 })
13 .catch((error) => {
14 console.error(error);
15 });
16}
17
18/*
19 * Promise resolves to:
20 *
21 * {
22 * "_createdDate": "2021-01-20T00:31:41Z",
23 * "_updatedDate": "2021-01-20T00:31:41Z"
24 * "namespace": "custom",
25 * "key": "custom.active-customer",
26 * "displayName": "Active Customer",
27 * "labelType": "USER_DEFINED"
28 * }
29 */