Retrieves a label by the specified label key.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function getLabel(key: string, options: GetLabelOptions): Promise<ContactLabel>;
Label key.
key
is generated when the label is created.
It can't be modified, even if displayName
is updated.
Language options.
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"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.