Search.../

deleteTask( )

Deletes a task by ID.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function deleteTask(taskId: string): Promise<void>

deleteTask Parameters

NAME
TYPE
DESCRIPTION
taskId
string

ID of the task to delete.

Returns

Return Type:

Promise<
void
>

Was this helpful?

Delete a task (dashboard page code)

Copy Code
1import { tasks } from 'wix-crm.v2';
2
3/* Sample taskId value:
4 * '3194f3f2-945f-4810-8905-d02b24f9e790'
5 */
6
7export async function myDeleteTaskFunction(taskId) {
8
9 try {
10 await tasks.deleteTask(taskId);
11
12 console.log('Task deleted.')
13 } catch (error) {
14 console.log(error);
15 //Handle the error
16 }
17}
Delete a task (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { tasks } from 'wix-crm.v2';
3import { elevate } from 'wix-auth';
4
5/* Sample taskId value:
6 * '3194f3f2-945f-4810-8905-d02b24f9e790'
7 */
8
9export const myDeleteTaskFunction = webMethod(Permissions.Anyone, async (taskId) => {
10
11 try {
12 const elevatedDeleteTask = elevate(tasks.deleteTask);
13 await elevatedDeleteTask(taskId);
14
15 console.log('Task deleted.')
16 } catch (error) {
17 console.log(error);
18 //Handle the error
19 }
20});
21