Search.../

getTask( )

Retrieves a task by ID.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function getTask(taskId: string): Promise<Task>

getTask Parameters

NAME
TYPE
DESCRIPTION
taskId
string

ID of the task to retrieve.

Returns

The retrieved task.

Return Type:

Promise<
Task
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time the task was created.

_id
string

Task ID.

_updatedDate
Date

Date and time the task was last updated.

contact
ContactInfo

Information about the contact associated with the task.

description
string

Description of the task.

dueDate
Date

Due date for the task.

revision
string

Revision number, which increments by 1 each time the task is updated. To prevent conflicting changes, the existing revision must be used when updating a task.

source
TaskSource

Details about the task source.

status
string

Status of the task.

Supported values: "ACTION_NEEDED", "COMPLETED".

Default: "ACTION_NEEDED"

title
string

Title of the task.

Was this helpful?

Get a task

Copy Code
1import { tasks } from 'wix-crm.v2';
2import { elevate } from 'wix-auth';
3
4/* Sample taskId value:
5 * '3194f3f2-945f-4810-8905-d02b24f9e790'
6 */
7
8export async function myGetTaskFunction(taskId) {
9
10 try {
11 const elevatedGetTask = elevate(tasks.getTask);
12 const task = await elevatedGetTask(taskId);
13
14 return task;
15 } catch(error){
16 console.log(error);
17 // Handle the error
18 }
19}
20
21/* Promise resolves to:
22 * {
23 * "revision": "1",
24 * "title": "Follow up",
25 * "description": "Send a follow up email",
26 * "status": "ACTION_NEEDED",
27 * "source": {
28 * "sourceType": "APP",
29 * "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a"
30 * },
31 * "contact": {
32 * "firstName": "Sally",
33 * "lastName": "Smith",
34 * "email": "sally.smith@example.com",
35 * "phone": "+1 524-624-2486",
36 * "_id": "5518ee7f-270e-40c4-b756-dad56e8f0ffc"
37 * },
38 * "_id": "3194f3f2-945f-4810-8905-d02b24f9e790",
39 * "_createdDate": "2024-01-18T11:35:29.092Z",
40 * "_updatedDate": "2024-01-18T11:35:29.092Z"
41 * }
42 */