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';23/* Sample taskId value:4 * '3194f3f2-945f-4810-8905-d02b24f9e790'5 */67export async function myDeleteTaskFunction(taskId) {89 try {10 await tasks.deleteTask(taskId);1112 console.log('Task deleted.')13 } catch (error) {14 console.log(error);15 //Handle the error16 }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';45/* Sample taskId value:6 * '3194f3f2-945f-4810-8905-d02b24f9e790'7 */89export const myDeleteTaskFunction = webMethod(Permissions.Anyone, async (taskId) => {1011 try {12 const elevatedDeleteTask = elevate(tasks.deleteTask);13 await elevatedDeleteTask(taskId);1415 console.log('Task deleted.')16 } catch (error) {17 console.log(error);18 //Handle the error19 }20});21