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