renameExtendedField( )
Renames an extended field.
Description
The renameExtendedField()
function returns a Promise that resolves when the specified extended field's display name is changed
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function renameExtendedField(key: string, field: RenameExtendedField): Promise<ExtendedField>
renameExtendedField 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.
Extended field to rename.
Returns
Updated extended 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:4 *5 * 'custom.nickname'6 *7 * Sample field value:8 * {9 * 'Contact Nickname'10 * }11 */1213export async function myRenameExtendedFieldFunction(key, field) {1415 try {16 const renamedExtendedField = await extendedFields.renameExtendedField(key, field);17 console.log('Successfulyl renamed extendedField:', renamedExtendedField);1819 return renamedExtendedField;20 } catch (error) {21 console.log(error);22 // Handle the error23 }24}2526/* Promise resolves to:27 * {28 * "namespace": "custom",29 * "key": "custom.nickname",30 * "displayName": "Contact Nickname",31 * "dataType": "TEXT",32 * "fieldType": "USER_DEFINED",33 * "legacyId": "63408eaf-e3d0-43f3-afa5-942847d272a1",34 * "wixSearchColumn": "info_extendedFields_custom_string_18",35 * "_createdDate": "2023-12-25T12:21:42.000Z",36 * "_updatedDate": "2023-12-25T13:25:35.000Z"37 * }38 */
1import { Permissions, webMethod } from 'wix-web-module';2import { extendedFields } from 'wix-crm.v2';3import { elevate } from 'wix-auth';45/* Sample key value:6 *7 * 'custom.nickname'8 *9 * Sample field value:10 * {11 * 'Contact Nickname'12 * }13 */1415export const myRenameExtendedFieldFunction = webMethod(Permissions.Anyone, async (key, field) => {1617 try {18 const elevatedRenameExtendedField = elevate(extendedFields.renameExtendedField);19 const renamedExtendedField = await elevatedRenameExtendedField(key, field) ;20 console.log('Successfulyl renamed extendedField:', renamedExtendedField);2122 return renamedExtendedField;23 } catch (error) {24 console.log(error);25 // Handle the error26 }27});2829/* Promise resolves to:30 * {31 * "namespace": "custom",32 * "key": "custom.nickname",33 * "displayName": "Contact Nickname",34 * "dataType": "TEXT",35 * "fieldType": "USER_DEFINED",36 * "legacyId": "63408eaf-e3d0-43f3-afa5-942847d272a1",37 * "wixSearchColumn": "info_extendedFields_custom_string_18",38 * "_createdDate": "2023-12-25T12:21:42.000Z",39 * "_updatedDate": "2023-12-25T13:25:35.000Z"40 * }41 */42