> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: updateTask(_id: string, task: UpdateTask, options: UpdateTaskOptions) # Method package: wixCrmV2 # Method menu location: wixCrmV2 --> tasks --> updateTask # Method Link: https://dev.wix.com/docs/velo/apis/wix-crm-v2/tasks/update-task.md # Method Description: 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. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Partially update a task (dashboard page code) ```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" * } */ ``` ## Partially update a task (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { tasks } from 'wix-crm.v2'; import { elevate } from 'wix-auth'; /* Sample _id value: * '3a49f901-62d5-4ca2-a8e8-395c562a3f7b' * * Sample task value: * { * revision: 2, * status: 'COMPLETED', * title: 'Send email * } */ export const myUpdateTaskFunction = webMethod(Permissions.Anyone, async (_id, task) => { try { const elevatedUpdateTask = elevate(tasks.updateTask); const updatedTask = await elevatedUpdateTask(_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" * } */ ``` ## Update task ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { tasks } from 'wix-crm.v2'; import { elevate } from 'wix-auth'; /* Sample _id value: * '3a49f901-62d5-4ca2-a8e8-395c562a3f7b' * * Sample task value: * { * revision: 3, * contact: { * _id: 'dfcb4c01-7336-4b59-ae43-957cb89952ce' * }, * description: 'Send follow up email email', * dueDate: new Date(2024, 3, 16), * status: 'ACTION_NEEDED', * title: 'Follow up' * } */ export const myUpdateTaskFunction = webMethod(Permissions.Anyone, async (_id, task) => { try { const elevatedUpdateTask = elevate(tasks.updateTask); const updatedTask = await elevatedUpdateTask(_id, task); return updatedTask; } catch (error) { console.log(error); // Handle the error } }); /* Promise resolves to: * { * "revision": "4", * "title": "Follow up", * "description": "Send follow up email email", * "dueDate": "2024-04-16T00:00:00.000Z", * "status": "ACTION_NEEDED", * "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:49:53.065Z" * } */ ``` ---