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:
Add the new import statement:
javascript | Copy Codeimport { tasks } from 'wix-crm.v2'If you plan to migrate all functions that use
wixCrmBackend
, remove the originalimport wixCrmBackend
statement.Look for any code that uses
wixCrmBackend.tasks.updateTaskFields()
, and replace it with withtasks.updateTask()
. Update your code to work with the newupdateTask()
call and response properties.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
ID of the task to update.
The information to update the task with.
Returns
Fulfilled - ID of the updated task.
Return Type:
Was this helpful?
1import { Permissions, webMethod } from 'wix-web-module';2import { tasks } from 'wix-crm-backend';34export const updateTaskFields = webMethod(Permissions.Anyone, (taskId, taskInfo) => {5 return tasks.updateTaskFields(taskId, taskInfo);6});78// Returns a promise that resolves to:9// "3c9683ea-f6cc-470b-b0d1-2eb6b8cea912"
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.
1import { Permissions, webMethod } from 'wix-web-module';2import { tasks } from 'wix-crm-backend';34export const updateTaskOneMonth = webMethod(Permissions.Anyone, (taskId) => {5 let date = new Date();6 date.setMonth(date.getMonth() + 1);78 const taskInfo = {9 "dueDate": date10 };1112 return tasks.updateTaskFields(taskId, taskInfo);13});1415// Returns a promise that resolves to:16// "3c9683ea-f6cc-470b-b0d1-2eb6b8cea912"
This example demonstrates how to delete a task's due date and contact information, while updating its title.
1import { Permissions, webMethod } from 'wix-web-module';2import { tasks } from 'wix-crm-backend';34export const updateTitle = webMethod(Permissions.Anyone, (taskId, newTitle) => {5 const taskInfo = {6 "title": newTitle,7 "dueDate": null,8 "contactId": null9 };1011 return tasks.updateTaskFields(taskId, taskInfo);12});1314// Returns a promise that resolves to:15// "3c9683ea-f6cc-470b-b0d1-2eb6b8cea912"