CorvidReference

Events

Events that are fired by actions relating to site contacts.

Wix CRM events are fired on your site's backend when certain events occur related to site contacts. You can write event handlers that react to these events. Event handler functions receive data that corresponds to the event that fired. Use event handlers to create custom responses to contact events.

To add a CRM event handler, add an events.js file to the Backend section of your site if one does not already exist. All event handler functions for your site are defined in this file.

Event handler functions are defined using the following pattern:

 export function <wixAppName>_<eventName>(event) { }

For example, an event handler that handles user form submittal looks like this:

 export function wixCRM_onFormSubmit(event) { }

Note that backend events don't work when previewing your site.

Table of Contents

onCardCreated( )

An event that fires when a new workflow card is created.

Description

The onCardCreated() event handler runs when a new workflow card is created programmatically using the createCard() function or manually in your site's Dashboard. The received CardCreatedEvent object contains information about the card that was created.

Note

Backend events don't work when previewing your site.

Syntax

function onCardCreated(event: CardCreatedEvent): void
PARAMETERS
?
Values that you pass to a function.
event
The created card's data.

Examples

An event when a card is created

// Place this code in the events.js file
// of your site's Backend section.

export function wixCrm_onCardCreated(event) {
  let workflowId = event.workflowId;
  let cardName = event.card.name;
}

/*  Full event object:
 *  {
 *    "workflowId": "f2cb00b5-9286-4d35-b41b-367d6fec43ce",
 *    "workflowName": "My Workflow",
 *    "phaseId": "ngp4030h-no3q-038h-c390-of40dn28pc9e",
 *    "phaseName": "To-do",
 *    "card": {
 *      "name": "This is a card.",
 *      "source": "Contacts",
 *      "id": "gd83brj9-34n8-ce8h-fh08-4e90cni3df89",
 *      "contactId": "ej8994ed-h3e9-uh2w-fhu0-vj013in3cej8",
 *      "createdAt": 2019-03-13T00:00:00.000Z,
 *      "updatedAt": 2019-06-12T00:00:00.000Z
 *    }
 *  }
 */

onCardMoved( )

An event that fires when a workflow card is moved.

Description

The onCardMoved() event handler runs when a workflow card is moved programmatically using the moveCard() function or manually in your site's Dashboard. The received CardMovedEvent object contains information about the card that was moved.

Note

Backend events don't work when previewing your site.

Syntax

function onCardMoved(event: CardMovedEvent): void
PARAMETERS
?
Values that you pass to a function.
event
The moved card's data.

Examples

An event when a card is moved

// Place this code in the events.js file
// of your site's Backend section.

export function wixCrm_onCardMoved(event) {
  let workflowId = event.workflowId;
  let cardName = event.card.name;
}

/*  Full event object:
 *  {
 *    "workflowId": "f2cb00b5-9286-4d35-b41b-367d6fec43ce",
 *    "workflowName": "n89f2df2-2919-43jk-3uio-v90se98s5ipf",
 *    "newPhaseId": "In Progress",
 *    "newPhaseName": "sd98iop3-87v3-ni4u-9438-vjc9hu8ec80w",
 *    "previousPhaseId": "b00831ee-cc5d-4447-81d7-2ca1828f07b2",
 *    "previousPhaseName": "To-do",
 *    "card": {
 *      "name": "This is a card.",
 *      "id": "gd83brj9-34n8-ce8h-fh08-4e90cni3df89",
 *      "contactId": "ej8994ed-h3e9-uh2w-fhu0-vj013in3cej8",
 *      "createdAt": 2019-03-13T00:00:00.000Z,
 *      "updatedAt": 2019-06-12T00:00:00.000Z
 *    }
 *  }
 */

onCardRestored( )

An event that fires when a workflow card is moved.

Description

The onCardRestored() event handler runs when a workflow card is restored programmatically using the restoreCard() function or manually in your site's Dashboard. The received CardRestoredEvent object contains information about the card that was restored.

Note

Backend events don't work when previewing your site.

Syntax

function onCardRestored(event: CardRestoredEvent): void
PARAMETERS
?
Values that you pass to a function.
event
The restored card's data.

Examples

An event when a card is restored

// Place this code in the events.js file
// of your site's Backend section.

export function wixCrm_onCardRestored(event) {
  let workflowId = event.workflowId;
  let cardName = event.card.name;
}

/*  Full event object:
 *  {
 *    "workflowId": "f2cb00b5-9286-4d35-b41b-367d6fec43ce",
 *    "workflowName": "My Workflow",
 *    "phaseId": "ngp4030h-no3q-038h-c390-of40dn28pc9e",
 *    "phaseName": "To-do",
 *    "card": {
 *      "name": "This is a card.",
 *      "source": "Contacts",
 *      "id": "gd83brj9-34n8-ce8h-fh08-4e90cni3df89",
 *      "contactId": "ej8994ed-h3e9-uh2w-fhu0-vj013in3cej8",
 *      "createdAt": 2019-03-13T00:00:00.000Z,
 *      "updatedAt": 2019-06-12T00:00:00.000Z
 *    }
 *  }
 */

onFormSubmit( )

An event that fires when a user submits a form.

Description

The onFormSubmit() event handler runs when a user submits a Wix form. The received FormSubmitEvent object contains information about the form that was submitted.

Note

Backend events don't work when previewing your site.

Syntax

function onFormSubmit(event: FormSubmitEvent): void
PARAMETERS
?
Values that you pass to a function.
event
The form data.

Examples

An event when a form is submitted

// Place this code in the events.js file
// of your site's Backend section.

export function wixCrm_onFormSubmit(event) {
  let formName = event.formName;
  let email = event.fields.email.value;
}

/*  Full event object:
 *  {
 *    "contactId": "f2cb00b5-9286-4d35-b41b-367d6fec43ce",
 *    "formName": "Feedback Form",
 *    "submissionTime": "2019-03-24T12:58:20.617Z",
 *    "submissionData": [
 *      {
 *        "fieldName": "First Name",
 *        "fieldValue": "John"
 *      },
 *      {
 *        "fieldName": "Last Name",
 *        "fieldValue": "Doe"
 *      },
 *      {
 *        "fieldName": "Email",
 *        "fieldValue": "john.doe@somedomain.com"
 *      }
 *    ],
 *    "attachments": [
 *      {
 *        "name": "flowers.jpg",
 *        "type": "IMAGE",
 *        "url": "wix:image://v1/68d3a9_1de7529c444b4c9eb38401f8efe0cad2.jpg/flowers.jpg#originWidth=1970&originHeight=112"
 *       },
 *      {
 *        "name": "SampleVideo_1280x720_10mb.mp4",
 *        "type": "VIDEO",
 *        "url": "wix:video://v1/80c05f_be1c421575e34915ad257571c4055ee4/SampleVideo_1280x720_10mb.mp4"
 *      }
 *    ]
 *  }
 */

CardCreatedEvent

An object representing a created card.

See Also

onCardCreated( )

Syntax

type CardCreatedEvent = {
  workflowId: string
  workflowName: string
  phaseId: string
  phaseName: string
  card: Card
}
MEMBERS
?
The properties of an object.
workflowId
string
ID of the card's workflow.
workflowName
string
Name of the card's workflow.
phaseId
string
ID of the card's phase.
phaseName
string
Name of the card's phase.
card
The card that was created.

Examples

An event when a card is created

// Place this code in the events.js file
// of your site's Backend section.

export function wixCrm_onCardCreated(event) {
  let workflowId = event.workflowId;
  let cardName = event.card.name;
}

/*  Full event object:
 *  {
 *    "workflowId": "f2cb00b5-9286-4d35-b41b-367d6fec43ce",
 *    "workflowName": "My Workflow",
 *    "phaseId": "ngp4030h-no3q-038h-c390-of40dn28pc9e",
 *    "phaseName": "To-do",
 *    "card": {
 *      "name": "This is a card.",
 *      "source": "Contacts",
 *      "id": "gd83brj9-34n8-ce8h-fh08-4e90cni3df89",
 *      "contactId": "ej8994ed-h3e9-uh2w-fhu0-vj013in3cej8",
 *      "createdAt": 2019-03-13T00:00:00.000Z,
 *      "updatedAt": 2019-06-12T00:00:00.000Z
 *    }
 *  }
 */

CardMovedEvent

An object representing a moved card.

See Also

onCardMoved( )

Syntax

type CardMovedEvent = {
  workflowId: string
  workflowName: string
  newPhaseId: string
  newPhaseName: string
  card: Card
  previousPhaseId: string
  previousPhaseName: string
}
MEMBERS
?
The properties of an object.
workflowId
string
ID of the card's workflow.
workflowName
string
Name of the card's workflow.
newPhaseId
string
ID of the card's new phase.
newPhaseName
string
Name of the card's new phase.
card
The card that was moved.
previousPhaseId
string
ID of the card's old phase.
previousPhaseName
string
Name of the card's old phase.

Examples

An event when a card is moved

// Place this code in the events.js file
// of your site's Backend section.

export function wixCrm_onCardMoved(event) {
  let workflowId = event.workflowId;
  let cardName = event.card.name;
}

/*  Full event object:
 *  {
 *    "workflowId": "f2cb00b5-9286-4d35-b41b-367d6fec43ce",
 *    "workflowName": "n89f2df2-2919-43jk-3uio-v90se98s5ipf",
 *    "newPhaseId": "In Progress",
 *    "newPhaseName": "sd98iop3-87v3-ni4u-9438-vjc9hu8ec80w",
 *    "previousPhaseId": "b00831ee-cc5d-4447-81d7-2ca1828f07b2",
 *    "previousPhaseName": "To-do",
 *    "card": {
 *      "name": "This is a card.",
 *      "id": "gd83brj9-34n8-ce8h-fh08-4e90cni3df89",
 *      "contactId": "ej8994ed-h3e9-uh2w-fhu0-vj013in3cej8",
 *      "createdAt": 2019-03-13T00:00:00.000Z,
 *      "updatedAt": 2019-06-12T00:00:00.000Z
 *    }
 *  }
 */

CardRestoredEvent

An object representing a moved card.

See Also

onCardRestored( )

Syntax

type CardRestoredEvent = {
  workflowId: string
  workflowName: string
  phaseId: string
  phaseName: string
  card: Card
}
MEMBERS
?
The properties of an object.
workflowId
string
ID of the workflow the card was restored to.
workflowName
string
Name of the workflow the card was restored to.
phaseId
string
ID of the phase the card was restored to.
phaseName
string
Name of the phase the card was restored to.
card
The card that was restored.

Examples

An event when a card is restored

// Place this code in the events.js file
// of your site's Backend section.

export function wixCrm_onCardRestored(event) {
  let workflowId = event.workflowId;
  let cardName = event.card.name;
}

/*  Full event object:
 *  {
 *    "workflowId": "f2cb00b5-9286-4d35-b41b-367d6fec43ce",
 *    "workflowName": "My Workflow",
 *    "phaseId": "ngp4030h-no3q-038h-c390-of40dn28pc9e",
 *    "phaseName": "To-do",
 *    "card": {
 *      "name": "This is a card.",
 *      "source": "Contacts",
 *      "id": "gd83brj9-34n8-ce8h-fh08-4e90cni3df89",
 *      "contactId": "ej8994ed-h3e9-uh2w-fhu0-vj013in3cej8",
 *      "createdAt": 2019-03-13T00:00:00.000Z,
 *      "updatedAt": 2019-06-12T00:00:00.000Z
 *    }
 *  }
 */

FormAttachment

An object representing an attachment to a form.

See Also

onFormSubmit( )

Syntax

type FormAttachment = {
  name: string
  url: string
  type: string
}
MEMBERS
?
The properties of an object.
name
string
Name of the attachment.
url
string
URL of the attachment.
type
string

Type of attachment. One of:

  • "UNDEFINED"
  • "DOCUMENT"
  • "IMAGE"
  • "VIDEO"

Examples

An event when a form is submitted

// Place this code in the events.js file
// of your site's Backend section.

export function wixCrm_onFormSubmit(event) {
  let formName = event.formName;
  let email = event.fields.email.value;
}

/*  Full event object:
 *  {
 *    "contactId": "f2cb00b5-9286-4d35-b41b-367d6fec43ce",
 *    "formName": "Feedback Form",
 *    "submissionTime": "2019-03-24T12:58:20.617Z",
 *    "submissionData": [
 *      {
 *        "fieldName": "First Name",
 *        "fieldValue": "John"
 *      },
 *      {
 *        "fieldName": "Last Name",
 *        "fieldValue": "Doe"
 *      },
 *      {
 *        "fieldName": "Email",
 *        "fieldValue": "john.doe@somedomain.com"
 *      }
 *    ],
 *    "attachments": [
 *      {
 *        "name": "flowers.jpg",
 *        "type": "IMAGE",
 *        "url": "wix:image://v1/68d3a9_1de7529c444b4c9eb38401f8efe0cad2.jpg/flowers.jpg#originWidth=1970&originHeight=112"
 *       },
 *      {
 *        "name": "SampleVideo_1280x720_10mb.mp4",
 *        "type": "VIDEO",
 *        "url": "wix:video://v1/80c05f_be1c421575e34915ad257571c4055ee4/SampleVideo_1280x720_10mb.mp4"
 *      }
 *    ]
 *  }
 */

FormField

An object representing a form field.

See Also

onFormSubmit( )

Syntax

type FormField = {
  fieldName: string
  fieldValue: string
}
MEMBERS
?
The properties of an object.
fieldName
string
Name of the field.
fieldValue
string
Value of the field.

Examples

An event when a form is submitted

// Place this code in the events.js file
// of your site's Backend section.

export function wixCrm_onFormSubmit(event) {
  let formName = event.formName;
  let email = event.fields.email.value;
}

/*  Full event object:
 *  {
 *    "contactId": "f2cb00b5-9286-4d35-b41b-367d6fec43ce",
 *    "formName": "Feedback Form",
 *    "submissionTime": "2019-03-24T12:58:20.617Z",
 *    "submissionData": [
 *      {
 *        "fieldName": "First Name",
 *        "fieldValue": "John"
 *      },
 *      {
 *        "fieldName": "Last Name",
 *        "fieldValue": "Doe"
 *      },
 *      {
 *        "fieldName": "Email",
 *        "fieldValue": "john.doe@somedomain.com"
 *      }
 *    ],
 *    "attachments": [
 *      {
 *        "name": "flowers.jpg",
 *        "type": "IMAGE",
 *        "url": "wix:image://v1/68d3a9_1de7529c444b4c9eb38401f8efe0cad2.jpg/flowers.jpg#originWidth=1970&originHeight=112"
 *       },
 *      {
 *        "name": "SampleVideo_1280x720_10mb.mp4",
 *        "type": "VIDEO",
 *        "url": "wix:video://v1/80c05f_be1c421575e34915ad257571c4055ee4/SampleVideo_1280x720_10mb.mp4"
 *      }
 *    ]
 *  }
 */

FormSubmitEvent

An object representing a form.

See Also

onFormSubmit( )

Syntax

type FormSubmitEvent = {
  contactId: string
  formName: string
  submissionTime: Date
  attachments: Array<FormAttachment>
  submissionData: Array<FormField>
}
MEMBERS
?
The properties of an object.
contactId
string
Contact ID of the user submitting the form.
formName
string
Name of the form.
submissionTime
Date
Date and time that the form was submitted.
attachments
The form's attachments.
submissionData
Array<FormField>
Data submitted in the form. The object contains key:value pairs where the key is the field name and the value is the contents of the field.

Examples

An event when a form is submitted

// Place this code in the events.js file
// of your site's Backend section.

export function wixCrm_onFormSubmit(event) {
  let formName = event.formName;
  let email = event.fields.email.value;
}

/*  Full event object:
 *  {
 *    "contactId": "f2cb00b5-9286-4d35-b41b-367d6fec43ce",
 *    "formName": "Feedback Form",
 *    "submissionTime": "2019-03-24T12:58:20.617Z",
 *    "submissionData": [
 *      {
 *        "fieldName": "First Name",
 *        "fieldValue": "John"
 *      },
 *      {
 *        "fieldName": "Last Name",
 *        "fieldValue": "Doe"
 *      },
 *      {
 *        "fieldName": "Email",
 *        "fieldValue": "john.doe@somedomain.com"
 *      }
 *    ],
 *    "attachments": [
 *      {
 *        "name": "flowers.jpg",
 *        "type": "IMAGE",
 *        "url": "wix:image://v1/68d3a9_1de7529c444b4c9eb38401f8efe0cad2.jpg/flowers.jpg#originWidth=1970&originHeight=112"
 *       },
 *      {
 *        "name": "SampleVideo_1280x720_10mb.mp4",
 *        "type": "VIDEO",
 *        "url": "wix:video://v1/80c05f_be1c421575e34915ad257571c4055ee4/SampleVideo_1280x720_10mb.mp4"
 *      }
 *    ]
 *  }
 */