Search...
onContactCreated( )
An event that triggers when a new contact is created.
Description
The onContactCreated()
event handler runs when a new
contact
is created.
The received ContactCreatedEvent
object
contains information about the contact that was created.
Note: Backend events don't work when previewing your site.
Syntax
function onContactCreated(event: ContactCreatedEvent): void
onContactCreated Parameters
NAME
TYPE
DESCRIPTION
event
ContactCreatedEvent
Information about the contact that was created 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 created
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.3// Add the file if it doesn't exist.45export function wixCrm_onContactCreated(event) {6 const contactId = event.metadata.entityId;7 const contactName = `${event.entity.info?.name?.first} ${event.entity.info?.name?.last}`;8 console.log('Contact created', event);9}1011/* Full event object:12 * {13 * "metadata": {14 * "id": "fde04f82-c5e4-442e-b70e-0fd3f506f2e8",15 * "entityId": "bea905ef-d7cb-49b9-bce7-19342d3e7ab3",16 * "eventTime": "2021-02-12T00:18:03.097922Z",17 * "triggeredByAnonymizeRequest": false18 * },19 * "entity": {20 * "_id": "bea905ef-d7cb-49b9-bce7-19342d3e7ab3",21 * "_createdDate": "2021-02-12T00:18:03.045Z",22 * "_updatedDate": "2021-02-12T00:18:03.046Z",23 * "revision": 0,24 * "info": {25 * "name": {26 * "first": "Ari",27 * "last": "Thereyet"28 * },29 * "extendedFields": {30 * "contacts.displayByFirstName": "Ari Thereyet",31 * "contacts.displayByLastName": "Thereyet Ari"32 * }33 * },34 * "source": {35 * "wixAppId": "v4.createContact"36 * },37 * "lastActivity": {38 * "activityDate": "2021-02-12T00:18:03.045Z",39 * "activityType": "CONTACT_CREATED"40 * }41 * }42 * }43 */