Retrieves a task by ID.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function getTask(taskId: string): Promise<Task>;
ID of the task to retrieve.
import { tasks } from "wix-crm.v2";
/* Sample taskId value:
* '3194f3f2-945f-4810-8905-d02b24f9e790'
*/
export async function myGetTaskFunction(taskId) {
try {
const task = await tasks.getTask(taskId);
return task;
} catch (error) {
console.log(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "revision": "1",
* "title": "Follow up",
* "description": "Send a follow up email",
* "status": "ACTION_NEEDED",
* "source": {
* "sourceType": "APP",
* "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a"
* },
* "contact": {
* "firstName": "Sally",
* "lastName": "Smith",
* "email": "sally.smith@example.com",
* "phone": "+1 524-624-2486",
* "_id": "5518ee7f-270e-40c4-b756-dad56e8f0ffc"
* },
* "_id": "3194f3f2-945f-4810-8905-d02b24f9e790",
* "_createdDate": "2024-01-18T11:35:29.092Z",
* "_updatedDate": "2024-01-18T11:35:29.092Z"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.