Search.../

renameExtendedField( )

Developer Preview

Renames an extended field.

Description

The renameExtendedField() function returns a Promise that resolves when the specified extended field's display name is changed

Admin Method

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
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.

field
RenameExtendedField

Extended field to rename.

Returns

Updated extended 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?

Rename an extended field (dashboard page code)

Copy Code
1import { extendedFields } from 'wix-crm.v2';
2
3/* Sample key value:
4 *
5 * 'custom.nickname'
6 *
7 * Sample field value:
8 * {
9 * 'Contact Nickname'
10 * }
11 */
12
13export async function myRenameExtendedFieldFunction(key, field) {
14
15 try {
16 const renamedExtendedField = await extendedFields.renameExtendedField(key, field);
17 console.log('Successfulyl renamed extendedField:', renamedExtendedField);
18
19 return renamedExtendedField;
20 } catch (error) {
21 console.log(error);
22 // Handle the error
23 }
24}
25
26/* 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 */
Rename an 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:
6 *
7 * 'custom.nickname'
8 *
9 * Sample field value:
10 * {
11 * 'Contact Nickname'
12 * }
13 */
14
15export const myRenameExtendedFieldFunction = webMethod(Permissions.Anyone, async (key, field) => {
16
17 try {
18 const elevatedRenameExtendedField = elevate(extendedFields.renameExtendedField);
19 const renamedExtendedField = await elevatedRenameExtendedField(key, field) ;
20 console.log('Successfulyl renamed extendedField:', renamedExtendedField);
21
22 return renamedExtendedField;
23 } catch (error) {
24 console.log(error);
25 // Handle the error
26 }
27});
28
29/* 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