Search.../

getTask( )

Deprecated. This function will continue to work, but a newer version is available at wix-crm.v2.Tasks.getTask().

Description

Migration Instructions

If this function is already in your code, it will continue to work. To stay compatible with future changes, migrate to wix-crm.v2.Tasks.getTask().

To migrate to the new function:

  1. Add the new import statement:

    import { tasks } from 'wix-crm.v2'
    javascript | Copy Code
  2. If you plan to migrate all functions that use wixCrmBackend, remove the original import wixCrmBackend statement.

  3. Look for any code that uses wixCrmBackend.tasks.getTask(), and replace it with with tasks.getTask(). Update your code to work with the new getTask() call and response properties.

  4. Test your changes to make sure your code behaves as expected.

Gets a task by ID.

The getTask() function returns a Promise that resolves to the task with the given ID.

Syntax

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

getTask Parameters

NAME
TYPE
DESCRIPTION
taskId
string

The ID of the task to get from the task list.

Returns

Fulfilled - The task with the given ID.

Return Type:

Promise<Task>
NAME
TYPE
DESCRIPTION
_id
string

Unique task identifier.

title
string

Task title.

dueDate
Date

Date the task is due.

contactId
string

Unique identifier of the site contact that this task is linked to.

isCompleted
boolean

Indicates whether the task has been completed.

version
number

Running task version number. Each time an action is performed on a task its version number is incremented.

creatorType
string

Type of the task's creator. "USER" if the task was created using the site's dashboard. "APP" if the task was created using the createTask() function or if it was created by an app installed on the site.

userId
string

When creatorType is "USER", the unique identifier of the user that created the task in the dashboard. Otherwise, userId is not present.

applicationId
string

When creatorType is "APP", the unique identifier of the application that created the task. Otherwise, applicationId is not present.

Was this helpful?

Get a task by ID

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { tasks } from 'wix-crm-backend';
3
4export const getTask = webMethod(Permissions.Anyone, (taskId) => {
5 return tasks.getTask(taskId);
6});
7
8/* Returns a promise that resolves to:
9 * {
10 * "_id": "6cb91509-7aa1-479b-a242-7327f58b7157",
11 * "title": "Add domain",
12 * "version": 9,
13 * "dueDate": "2019-01-22T10:00:00Z",
14 * "contactId": "6cb91509-7aa1-479b-a242-7327f58b7157",
15 * "isCompleted": false,
16 * "applicationId: "791f5e4f-5377-47a9-bd8e-cc0ef4605c8f",
17 * "creatorType": "APP"
18 * }
19 */