Search.../

updateTaskFields( )

Updates the specified fields of an existing task.

Description

The updateTaskFields() function returns a Promise that resolves to the ID of the the updated task after it has been successfully updated.

Only the properties passed in the TaskInfo object will be updated. All other properties will remain the same.

To remove a value from the task, pass its corresponding property with a value of null.

Syntax

function updateTaskFields(taskId: string, taskInfo: TaskInfo): Promise<string>

updateTaskFields Parameters

NAME
TYPE
DESCRIPTION
taskId
string

ID of the task to update.

taskInfo
TaskInfo

The information to update the task with.

Returns

Fulfilled - ID of the updated task.

Return Type:

Promise<string>

Was this helpful?

Update a task

Copy Code
1import {tasks} from 'wix-crm-backend';
2
3export function updateTaskFields(taskId, taskInfo) {
4 return tasks.updateTaskFields(taskId, taskInfo);
5}
6
7// Returns a promise that resolves to:
8// "3c9683ea-f6cc-470b-b0d1-2eb6b8cea912"
Update some of a task's info

This example demonstrates how to update only the due date of a given task to a month from today, while leaving the rest of the task's information as it was before the update.

Copy Code
1import {tasks} from 'wix-crm-backend';
2
3export function updateTaskOneMonth(taskId) {
4 let date = new Date();
5 date.setMonth(date.getMonth() + 1);
6
7 const taskInfo = {
8 "dueDate": date
9 };
10
11 return tasks.updateTaskFields(taskId, taskInfo);
12}
13
14// Returns a promise that resolves to:
15// "3c9683ea-f6cc-470b-b0d1-2eb6b8cea912"
16
Update some of a task's info and delete some info

This example demonstrates how to delete a task's due date and contact information, while updating its title.

Copy Code
1import {tasks} from 'wix-crm-backend';
2
3export function updateTitle(taskId, newTitle) {
4 const taskInfo = {
5 "title": newTitle,
6 "dueDate": null,
7 "contactId": null
8 };
9
10 return tasks.updateTaskFields(taskId, taskInfo);
11}
12
13// Returns a promise that resolves to:
14// "3c9683ea-f6cc-470b-b0d1-2eb6b8cea912"
15