How to remove Task for closed Deal?

How to remove Task for closed Deal?

Hi,

I found an interesting script in your KB which can close all tasks assigned to a Deal. https://www.zoho.com/crm/resources/tips/auto-close-tasks-based-on-deal-stages.html I changed it to remove the tasks instead of close them but it doesn't work. There is a message:
Failed to save the function
  • delete function cant be assigned to variable or used in expression Line Number: 10

Could you advise me what's wrong with that code?
  1. relatedTask = zoho.crm.getRelatedRecords("Tasks","Deals",dealId.toLong(),1,200);
  2. //info relatedTask;

  3. for each task in relatedTask
  4. {
  5. taskID = ifnull(task.get("id"),"");
  6. status = ifnull(task.get("Status"),"");
  7. if(status != "Zakończone")
  8. {
  9. deleteTask = zoho.crm.delete("Tasks",taskID.toLong());
  10. info deleteTask;
  11. }
  12. }