getLabel( )


Retrieves a label by the specified label key.

Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Bookings Services and Settings
Manage Contact Labels
Manage Portfolio
Manage Members and Contacts - all permissions
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function getLabel(key: string, options: GetLabelOptions): Promise<ContactLabel>;
Method Parameters
keystringRequired

Label key.

key is generated when the label is created. It can't be modified, even if displayName is updated.


optionsGetLabelOptions

Language options.

Returns
Return Type:Promise<ContactLabel>
JavaScript
import { labels } from "wix-crm.v2"; /* Sample key value: 'custom.at-risk' */ export async function myGetLabelFunction(key) { try { const label = await labels.getLabel(key); console.log("successfully retrieved label:", label); return label; } catch (error) { console.log(error); // Handle the error } } /* Promise resolves to: * { * "namespace": "custom", * "namespaceDisplayName": "Labels", * "key": "custom.at-risk", * "displayName": "At Risk", * "labelType": "USER_DEFINED", * "legacyId": "65bd6a68-e10e-4831-8d92-c90e75be1570", * "_createdDate": "2023-12-25T08:38:36.000Z", * "_updatedDate": "2023-12-25T08:38:36.000Z" * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?