// Construct parameter to filter the open tasks
taskParam = Map();
taskParam.put("status","notcompleted");
taskParam.put("milestone_id",milestoneId);
// Invoke get tasks API
//Add your connection name as last parameter
taskResponse = zoho.projects.getRecords(portalId,projectId,"tasks",taskParam,1,"zpmsautocomplete");
info taskResponse;
// Variable declaration and assign value , Endpoint of the API
// This Varibale used to decide the milestone completion
isMilestoneUpdate = false;
// If task response is empty it will check any open bugs are available
if(taskResponse.isEmpty())
{
// construct parameter for filter only open bugs
milestoneList = list();
milestoneList.add(milestoneId);
bugParam = Map();
bugParam.put("statustype","open");
bugParam.put("milestone",milestoneList);
info "bugParam:" + bugParam;
//Add your connection name as last parameter
bugResponse = zoho.projects.getRecords(portalId,projectId,"bugs",bugParam,1,"zpmsautocomplete");
info bugResponse;
if(bugResponse.isEmpty())
{
isMilestoneUpdate = true;
}
}
info "TaskResponse Is Empty :" + taskResponse.isEmpty() + ", isMilestoneUpdate:" + isMilestoneUpdate;
info "---------------------";
if(!milestoneId.isNull() && isMilestoneUpdate)
{
//Modify the status of the milestone.(1 - notcompleted, 2 - completed)
milestoneParam = Map();
milestoneParam.put("status",2);
info milestoneParam;
info "---------------------";
// Enter The Connection option Example : connection:"your_conection_name"
updateMilestoneResponse = invokeurl
[
url :projectsAPIEndPoint + "/portal/" + portalId + "/projects/" + projectId + "/milestones/" + milestoneId + "/status/"
type :POST
parameters:milestoneParam
connection:"zpmsautocomplete"
];
info updateMilestoneResponse;
info "-------------------------------------";
}
return "success";