Search.../

onTaskCreated( )

An event that triggers when a new task is created.

Description

The onTaskCreated() event handler runs when a new task is created. The received TaskCreated object contains information about the task that was created.

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

Syntax

function wixCrmTasks_onTaskCreated(event: TaskCreated): void

onTaskCreated Parameters

NAME
TYPE
DESCRIPTION
event
Optional
TaskCreated

Information about the task 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 task is created

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 wixCrmTasks_onTaskCreated(event) {
6 const eventId = event.metadata.id;
7 const entityId = event.entity._id;
8 const title = event.entity.title;
9 console.log('Task created', event);
10}
11
12/* Full event object:
13 * {
14 * "metadata": {
15 * "id": "bd6c5959-5e88-4509-b7c3-fd17b41840eb",
16 * "entityId": "941ddd7a-5c3c-4bec-923e-fd6747f23e3f",
17 * "eventTime": "2024-01-21T06:52:40.743280247Z",
18 * "triggeredByAnonymizeRequest": false
19 * },
20 * "entity": {
21 * "revision": "1",
22 * "title": "Send follow up email",
23 * "dueDate": "2024-01-31T10:00:00.000Z",
24 * "status": "ACTION_NEEDED",
25 * "source": {
26 * "sourceType": "USER",
27 * "userId": "162e6672-d392-42f8-bf79-999ee633c92a"
28 * },
29 * "_id": "941ddd7a-5c3c-4bec-923e-fd6747f23e3f",
30 * "_createdDate": "2024-01-21T06:52:40.738Z",
31 * "_updatedDate": "2024-01-21T06:52:40.738Z"
32 * }
33 * }
34 */