getExtendedField( )
Retrieves an extended field.
Description
The getExtendedField()
function returns a Promise that resolves when the extended field is retrieved.
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
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:
NAME
TYPE
DESCRIPTION
Date and time the field was created.
Date and time the field was last updated.
Type of data the field holds.
One of:
"TEXT"
: Accepts strings."NUMBER"
: Accepts floats."DATE"
: Accepts dates formatted asYYYY-MM-DD
."URL"
: Accepts strings. Prependshttps://
if no protocol is included.
Field description, if the field is a system field.
Display name shown in the Contact List.
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.
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.
Extended field namespace.
Extended fields created by site collaborators or 3rd-party apps
are automatically assigned to the custom
namespace.
Was this helpful?
1import { extendedFields } from 'wix-crm.v2';23/* Sample key value: 'custom.nickname' */45export async function myGetExtendedFieldFunction(key) {67 try {8 const extendedField = await extendedFields.getExtendedField(key);9 console.log('Successfully retrieved extended field:', extendedField);1011 return extendedField;12 } catch (error) {13 console.log(error);14 // Handle the error15 }16}1718/*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 */
1import { Permissions, webMethod } from 'wix-web-module';2import { extendedFields } from 'wix-crm.v2';3import { elevate } from 'wix-auth';45/* Sample key value: 'custom.nickname' */67export const myGetExtendedFieldFunction = webMethod(Permissions.Anyone, async (key) => {89 try {10 const elevatedGetExtendedField = elevate(extendedFields.getExtendedField);11 const extendedField = await elevatedGetExtendedField(key);12 console.log('Successfully retrieved extended field:', extendedField);1314 return extendedField;15 } catch (error) {16 console.log(error);17 // Handle the error18 }19});2021/*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
1import { Permissions, webMethod } from 'wix-web-module';2import { extendedFields } from 'wix-crm.v2';3import { elevate } from 'wix-auth';45export 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;1011 return nicknameType12 } catch (error) {13 console.log(error);14 // Handle the error15 }16});1718// Return value: "TEXT"