Search.../

updateTaskFields( )

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

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.updateTask().

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.updateTaskFields(), and replace it with with tasks.updateTask(). Update your code to work with the new updateTask() call and response properties.

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

Updates the specified fields of an existing task.

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 { Permissions, webMethod } from 'wix-web-module';
2import { tasks } from 'wix-crm-backend';
3
4export const updateTaskFields = webMethod(Permissions.Anyone, (taskId, taskInfo) => {
5 return tasks.updateTaskFields(taskId, taskInfo);
6});
7
8// Returns a promise that resolves to:
9// "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 { Permissions, webMethod } from 'wix-web-module';
2import { tasks } from 'wix-crm-backend';
3
4export const updateTaskOneMonth = webMethod(Permissions.Anyone, (taskId) => {
5 let date = new Date();
6 date.setMonth(date.getMonth() + 1);
7
8 const taskInfo = {
9 "dueDate": date
10 };
11
12 return tasks.updateTaskFields(taskId, taskInfo);
13});
14
15// Returns a promise that resolves to:
16// "3c9683ea-f6cc-470b-b0d1-2eb6b8cea912"
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 { Permissions, webMethod } from 'wix-web-module';
2import { tasks } from 'wix-crm-backend';
3
4export const updateTitle = webMethod(Permissions.Anyone, (taskId, newTitle) => {
5 const taskInfo = {
6 "title": newTitle,
7 "dueDate": null,
8 "contactId": null
9 };
10
11 return tasks.updateTaskFields(taskId, taskInfo);
12});
13
14// Returns a promise that resolves to:
15// "3c9683ea-f6cc-470b-b0d1-2eb6b8cea912"