CRM Quotes- Delete tasks when status is changed
Hello. We have our quotes setup for approval process. We would like however to delete the tasks that are made when a different quote stage is selected. So when a quote stage is setup for "sent for review" we have the automation process to send out an email notification and setup the tasks as a reminder. We would like to delete the tasks once the quote stage is setup for approval/confirmed. How can I do this? I found the below code from another posts however it is given me errors. I modified to try to use the quote module also.
outstanding_tasks_to_close = zoho.crm.getRelatedRecords("Tasks","Quotes",Quote_id);
for each task in outstanding_tasks_to_close
{
if(task.get("Status") != "Approved/Confirmed")
{
update_payload = {"Status":"Approved/Confirmed"};
update_resp = zoho.crm.updateRecord("Tasks",task.get("id"),update_payload);
}
}