Search.../

getExtendedField( )

Developer Preview

Retrieves an extended field.

Description

The getExtendedField() function returns a Promise that resolves when the extended field is retrieved.

Admin Method

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

Syntax

function getExtendedField(key: string): Promise<ExtendedField>

getExtendedField Parameters

NAME
TYPE
DESCRIPTION
key
string

Extended field key.

When accessing contact data, extended field values are available at fields[key]. For example, if the key is "custom.notes", the value can be accessed at fields["custom.notes"].

Once set, key cannot be modified, even if displayName changes.

Returns

The specified field.

Return Type:

Promise<
ExtendedField
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time the field was created.

_updatedDate
Date

Date and time the field was last updated.

dataType
string

Type of data the field holds.

One of:

  • "TEXT": Accepts strings.
  • "NUMBER": Accepts floats.
  • "DATE": Accepts dates formatted as YYYY-MM-DD.
  • "URL": Accepts strings. Prepends https:// if no protocol is included.
description
string

Field description, if the field is a system field.

displayName
string

Display name shown in the Contact List.

fieldType
string

Indicates whether the extended field is a system field or custom field.

One of:

  • "SYSTEM": System field managed by Wix. System fields cannot be modified by 3rd-party apps or site contributors.
  • "USER_DEFINED": Custom field that can be modified by 3rd-party apps or site admins.
key
string

Extended field key.

When accessing contact data, extended field data is available at fields[key]. For example, if the key is "custom.notes", the value can be accessed at fields["custom.notes"].

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

namespace
string

Extended field namespace.

Extended fields created by site collaborators or 3rd-party apps are automatically assigned to the custom namespace.

Was this helpful?

Get a specified extended field (dashboard page code)

Copy Code
1import { extendedFields } from 'wix-crm.v2';
2
3/* Sample key value: 'custom.nickname' */
4
5export async function myGetExtendedFieldFunction(key) {
6
7 try {
8 const extendedField = await extendedFields.getExtendedField(key);
9 console.log('Successfully retrieved extended field:', extendedField);
10
11 return extendedField;
12 } catch (error) {
13 console.log(error);
14 // Handle the error
15 }
16}
17
18/*
19 * Promise resolves to:
20 * {
21 * "namespace": "custom",
22 * "key": "custom.nickname",
23 * "displayName": "Nickname",
24 * "dataType": "TEXT",
25 * "fieldType": "USER_DEFINED",
26 * "legacyId": "63408eaf-e3d0-43f3-afa5-942847d272a1",
27 * "wixSearchColumn": "info_extendedFields_custom_string_18",
28 * "_createdDate": "2023-12-25T12:21:42.000Z",
29 * "_updatedDate": "2023-12-25T12:22:25.000Z"
30 * }
31 */
Get a specified extended field (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { extendedFields } from 'wix-crm.v2';
3import { elevate } from 'wix-auth';
4
5/* Sample key value: 'custom.nickname' */
6
7export const myGetExtendedFieldFunction = webMethod(Permissions.Anyone, async (key) => {
8
9 try {
10 const elevatedGetExtendedField = elevate(extendedFields.getExtendedField);
11 const extendedField = await elevatedGetExtendedField(key);
12 console.log('Successfully retrieved extended field:', extendedField);
13
14 return extendedField;
15 } catch (error) {
16 console.log(error);
17 // Handle the error
18 }
19});
20
21/*
22 * Promise resolves to:
23 * {
24 * "namespace": "custom",
25 * "key": "custom.nickname",
26 * "displayName": "Nickname",
27 * "dataType": "TEXT",
28 * "fieldType": "USER_DEFINED",
29 * "legacyId": "63408eaf-e3d0-43f3-afa5-942847d272a1",
30 * "wixSearchColumn": "info_extendedFields_custom_string_18",
31 * "_createdDate": "2023-12-25T12:21:42.000Z",
32 * "_updatedDate": "2023-12-25T12:22:25.000Z"
33 * }
34 */
35
Get the dataType for the specified extended field

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { extendedFields } from 'wix-crm.v2';
3import { elevate } from 'wix-auth';
4
5export const myGetExtendedFieldFunction = webMethod(Permissions.Anyone, async (key) => {
6 try {
7 const elevatedGetExtendedField = elevate(extendedFields.getExtendedField);
8 const extendedField = await elevatedGetExtendedField(key);
9 const nicknameType = extendedField.dataType;
10
11 return nicknameType
12 } catch (error) {
13 console.log(error);
14 // Handle the error
15 }
16});
17
18// Return value: "TEXT"