Search.../

onContactUpdated( )

Developer Preview

An event that triggers when a contact is updated.

Description

The onContactUpdated() event handler runs when a contact is updated.

The received ContactUpdatedEvent object contains information about the contact that was updated. If a contact is updated as part of a merge, metadata.originatedFrom is sent as "merge". Otherwise, originatedFrom is omitted.

Note: Backend events don't work when previewing your site.

Syntax

function wixCrm_onContactUpdated(event: ContactUpdated): void

onContactUpdated Parameters

NAME
TYPE
DESCRIPTION
event
Optional
ContactUpdated

Information about the contact that was updated and metadata for the event.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

An event fired when a contact is updated

Copy Code
1// Place this code in the events.js file
2// of your site's Backend section.
3// Add the file if it doesn't exist.
4
5export function wixCrm_onContactUpdated(event) {
6 const eventId = event.metadata.id;
7 const entityId = event.entity._id;
8 const lastName = event.entity.info.name.last;
9}
10
11/* Full event object:
12 * {
13 * "metadata": {
14 * "id": "7bdca23b-a89c-48a1-be76-6dcf46fc4edb",
15 * "entityId": "beeb8dc1-93d6-49f3-9389-18a9997f554f",
16 * "eventTime": "2024-01-10T11:28:27.479909037Z",
17 * "triggeredByAnonymizeRequest": false
18 * },
19 * "entity": {
20 * "_id": "beeb8dc1-93d6-49f3-9389-18a9997f554f",
21 * "revision": 2,
22 * "source": {
23 * "sourceType": "ADMIN"
24 * },
25 * "_createdDate": "2024-01-10T10:30:27.447Z",
26 * "_updatedDate": "2024-01-10T11:28:27.447Z",
27 * "primaryInfo": {
28 * "email": "fforte@example.com",
29 * "phone": "646-446-4789"
30 * },
31 * "lastActivity": {
32 * "activityDate": "2024-01-10T11:28:27.446Z",
33 * "activityType": "CONTACT_UPDATED"
34 * },
35 * "info": {
36 * "name": {
37 * "first": "Franky",
38 * "last": "Forte"
39 * },
40 * "emails": [
41 * {
42 * "tag": "UNTAGGED",
43 * "email": "fforte@example.com",
44 * "primary": true,
45 * "_id": "c27570d4-fc36-4391-aeb4-216b65ebb5e9"
46 * }
47 * ],
48 * "phones": [
49 * {
50 * "tag": "MOBILE",
51 * "countryCode": "US",
52 * "phone": "646-446-4789",
53 * "e164Phone": "+16464464789",
54 * "formattedPhone": "+1 646-446-4789",
55 * "primary": true,
56 * "_id": "412ccdb6-b5de-441f-ad9f-a32637357c98"
57 * },
58 * {
59 * "tag": "WORK",
60 * "countryCode": "US",
61 * "phone": "718-250-2680",
62 * "e164Phone": "+17182502680",
63 * "formattedPhone": "+1 718-250-2680",
64 * "primary": false,
65 * "_id": "90148d5d-4940-4761-9a30-6c677c92fa3e"
66 * }
67 * ],
68 * "addresses": [
69 * {
70 * "_id": "19d2ab15-0c8e-4f2c-894a-eddaba1088cf",
71 * "tag": "BILLING",
72 * "address": {
73 * "formatted": "82 Howard Ave\nNew York, New York 11598\nUnited States",
74 * "subdivision": "US-NY",
75 * "city": "New York",
76 * "country": "US",
77 * "postalCode": "11598",
78 * "addressLine1": "82 Howard Ave"
79 * }
80 * }
81 * ],
82 * "labelKeys": [
83 * "contacts.customers"
84 * ],
85 * "extendedFields": {
86 * "invoices.vatId": "",
87 * "contacts.displayByFirstName": "Franky Forte",
88 * "contacts.displayByLastName": "Forte Franky"
89 * }
90 * }
91 * }
92 * }
93 */
94