Search.../

getLabel( )

Developer Preview

Retrieves a label by the specified label key.

Description

The getLabel() function returns a Promise that resolves when the specified label is retrieved.

This function is not a universal function and runs only on the backend.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function getLabel(key: string, options: GetLabelOptions): Promise<ContactLabel>

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
GetLabelOptions

Language options.

Returns

The specified label.

Return Type:

Promise<
ContactLabel
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time the label was created.

_updatedDate
Date

Date and time the label was last updated.

displayName
string

Label display name shown in the Dashboard.

key
string

Label key.

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

labelType
string

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.
namespace
string

Label namespace.

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

namespaceDisplayName
string

Display name for the namespace, used to organize the list of labels in the site Dashboard.

Was this helpful?

Get a label

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