updateTask( )


Updates a task.

Each time the task is updated, revision increments by 1. The existing revision must be included when updating the task. This ensures you're working with the latest task and prevents unintended overwrites.

Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Tasks
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function updateTask(
  _id: string,
  task: UpdateTask,
  options: UpdateTaskOptions,
): Promise<Task>;
Method Parameters
_idstringRequired

Task ID.


taskUpdateTaskRequired

Task to update.


optionsUpdateTaskOptions
Returns
Return Type:Promise<Task>
JavaScript
import { tasks } from "wix-crm.v2"; /* Sample _id value: * '3a49f901-62d5-4ca2-a8e8-395c562a3f7b' * * Sample task value: * { * revision: 2, * status: 'COMPLETED', * title: 'Send email * } */ export async function myUpdateTaskFunction(_id, task) { try { const updatedTask = await tasks.updateTask(_id, task); return updatedTask; } catch (error) { console.log(error); // Handle the error } } /* Promise resolves to: * { * "revision": "3", * "title": "Send email", * "dueDate": "2024-02-08T10:00:00.000Z", * "status": "COMPLETED", * "source": { * "sourceType": "USER", * "userId": "162e6672-d392-42f8-bf79-999ee633c92a" * }, * "contact": { * "firstName": "Jane", * "lastName": "Doe", * "email": "jane.doe1@example.com", * "phone": "+1 214-533-2543", * "_id": "dfcb4c01-7336-4b59-ae43-957cb89952ce" * }, * "_id": "3a49f901-62d5-4ca2-a8e8-395c562a3f7b", * "_createdDate": "2024-01-18T13:40:56.414Z", * "_updatedDate": "2024-01-18T15:44:52.606Z" * } */
Errors
400Invalid Argument

There is 1 error with this status code.

This method may also return standard errors. Learn more about standard Wix errors.

Did this help?