Deluge Script to Reopen Ticket if Tasks are not Completed
I have the following script, my goal is to have it automatically reopen the ticket when the ticket is closed if there are Activities assigned to the ticket that are not "Completed". This script seems to reopen the ticket if there are any tasks at all, and does not distinguish whether the task is "Completed" or not. This runs as a workflow when a ticket is changed to "Closed". What can I do to make it only reopen the ticket if the tasks are not in the "Completed" status?
- count = 0;
- response = invokeurl
- [
- url :"https://desk.zoho.com/api/v1/tickets/" + ticket_id + "/tasks?include=assignee,tickets,contacts,teams"
- type :GET
- connection:"zdesk"
- ];
- if(response.getJson("data").size() > 0)
- {
- if(response.getJson("status") != "Completed")
- {
- count = 1;
- }
- }
- if(count == 1)
- {
- m = Map();
- m.put("status","Open");
- response = invokeurl
- [
- url :"https://desk.zoho.com/api/v1/tickets/" + ticket_id + ""
- type :PATCH
- parameters:m.toString()
- connection:"zdesk"
- ];
- info response;
- }