An event that triggers when a contact is deleted.
The onContactDeleted()
event handler runs when a
contact
is deleted.
The received ContactDeletedEvent
object
contains event metadata.
If a contact is deleted 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.
Metadata for the event.
An event that triggers when one or more source contacts are merged into a target contact.
The onContactMerged()
event handler runs when a
contact
is merged.
The received ContactMergedEvent
object
contains event metadata.
Merging contacts triggers these events:
onContactMerged()
is triggered.onContactUpdated()
is triggered for the target contact. metadata.originatedFrom
is sent as "merge"
.onContactDeleted()
is triggered for each source contact. metadata.originatedFrom
is sent as "merge"
.If you handle the originating merge event,
you can ignore update and delete events where metadata.originatedFrom
is set to "merge"
.
When onContactUpdated()
and onContactDeleted()
are not triggered from a merge,
originatedFrom
is omitted from their event object.
Note: Backend events don't work when previewing your site.
Information about the source and target contacts, and metadata for the event.
An event that triggers when a contact is updated.
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.
function onContactUpdated(event: ContactUpdatedEvent): void;
Information about the contact that was updated and metadata for the event.
// Place this code in the events.js file
// of your site's Backend section.
// Add the file if it doesn't exist.
export function wixCrm_onContactUpdated(event) {
const contactId = event.metadata.entityId;
const contactName = `${event.entity.info?.name?.first} ${event.entity.info?.name?.last}`;
console.log("Contact updated", event);
}
/* Full event object:
* {
* "metadata": {
* "id": "74cb6d78-21c8-42a6-aa7b-e9128e1c77e6",
* "entityId": "bc0ae72b-3285-485b-b0ad-c32c769a4daf",
* "eventTime": "2021-04-07T21\:03\:39.731445Z",
* "triggeredByAnonymizeRequest": false
* },
* "entity": {
* "_id": "bc0ae72b-3285-485b-b0ad-c32c769a4daf",
* "_createdDate": "2021-03-30T13\:12\:39.649Z",
* "_updatedDate": "2021-04-07T21\:03\:39.481Z",
* "revision": 2,
* "primaryInfo": {
* "email": "gene.lopez.at.home@example.com",
* "phone": "(722)-138-3099"
* },
* "info": {
* "name": {
* "first": "Gene",
* "last": "Lopez"
* },
* "extendedFields": {
* "contacts.displayByLastName": "Lopez Gene",
* "emailSubscriptions.deliverabilityStatus": "NOT_SET",
* "emailSubscriptions.subscriptionStatus": "NOT_SET",
* "custom.event-we-met-at": "LegalBigData",
* "emailSubscriptions.effectiveEmail": "gene.lopez.at.home@example.com",
* "contacts.displayByFirstName": "Gene Lopez"
* },
* "locale": "en-us",
* "company": "Borer and Sons, Attorneys at Law",
* "phones": [
* {
* "tag": "MOBILE",
* "_id": "820e4640-ffe0-4980-a097-62a715e73135",
* "countryCode": "US",
* "primary": true,
* "phone": "(722)-138-3099"
* },
* {
* "tag": "HOME",
* "_id": "8506549e-e4f8-42f6-b6fc-9db155b582ef",
* "countryCode": "US",
* "e164Phone": "+17044541233",
* "primary": false,
* "phone": "(704)-454-1233"
* }
* ],
* "birthdate": "1981-11-02",
* "labelKeys": [
* "contacts.contacted-me",
* "custom.new-lead"
* ],
* "picture": {
* "image": "https://randomuser.me/api/portraits/men/0.jpg",
* "imageProvider": "EXTERNAL"
* },
* "jobTitle": "Senior Staff Attorney",
* "emails": [
* {
* "tag": "HOME",
* "email": "gene.lopez.at.home@example.com",
* "primary": true,
* "_id": "5bdcce4a-37c2-46ed-b49c-d562c6e3c4ce"
* },
* {
* "tag": "WORK",
* "email": "gene.lopez@example.com",
* "primary": false,
* "_id": "78e5f398-e148-448d-b490-7c0b7d2ab336"
* }
* ],
* "addresses": [
* {
* "_id": "8532051f-91f2-42d9-9a97-9f2c39e64f7a",
* "tag": "HOME",
* "address": {
* "city": "El Cajon",
* "location": {
* "latitude": 84.1048,
* "longitude": -116.8836
* },
* "streetAddress": {
* "number": "9834",
* "name": "Bollinger Rd"
* },
* "formatted": "9834 Bollinger Rd\nEl Cajon, WY 97766\nUS",
* "country": "US",
* "postalCode": "97766",
* "subdivision": "US-WY"
* }
* }
* ]
* },
* "lastActivity": {
* "activityDate": "2021-03-30T13\:12\:39.649Z",
* "activityType": "CONTACT_CREATED"
* },
* "source": {
* "appId": "v4.createContact"
* }
* }
* }
*/