Custom Function helps in populating the task fields automatically. If you have multiple default and custom fields in the tasks and it will be tough to enter the values manually. Also, this will be time consuming to update the values for multiple tasks across projects. We can avoid this manual process using the custom function.
Let’s take the below scenario where one customer would like to auto update the owner of the sub tasks same as task owner. For example, David is the owner of the parent task then David should be owner for all the sub tasks under this task.
We have successfully accomplished this requirement via custom Functions. Here is the code.
// TODO: Please create a connection for the Zoho Projects service with the scopes "ZohoProjects.tasks.READ, ZohoProjects.projects.READ, ZohoProjects.tasks.UPDATE". Replace 'xxxxxxxxx' with the connection name. Click this link below to learn how to create the connection.
task = invokeurl
[
url :APIEndPoint + "/portal/" + portalId + "/projects/" + projectId + "/tasks/" + taskId + "/"
type :Get
connection:”********”
];
isparent = task.get("tasks").get(0).get("isparent");
parentid = task.get("tasks").get(0).get("parent_task_id");
if(isparent != null)
{
parenttask = invokeurl
[
url :APIEndPoint + "/portal/" + portalId + "/projects/" + projectId + "/tasks/" + parentid + "/"
type :Get
connection:”*********”
];
m = "";
owners = parenttask.get("tasks").get(0).get("details").get("owners");
for each owner in owners
{
id = owner.get("id");
m = m + id + ",";
}
param = Map();
param.put("person_responsible",m);
info param;
subtasksdetails = invokeurl
[
url :APIEndPoint + "/portal/" + portalId + "/projects/" + projectId + "/tasks/" + parentid + "/subtasks/"
type :GET
connection:”********
];
subtasks = subtasksdetails.getJSON("tasks");
for each subtask in subtasks
{
subtaskId = subtask.get("id");
subtaskPost = invokeurl
[
url :APIEndPoint + "/portal/" + portalId + "/projects/" + projectId + "/tasks/" + subtaskId + "/"
type :Post
parameters:param
connection:”**********”
];
}
}
return "success";
Conclusion ::
By using custom functions in Zoho Projects, you can automate the task updates and save your time and effort. This custom function is just one example of how you can use custom functions. With a little bit of creativity, you can create custom functions that suit your specific project needs.
Watch this space for more custom function codes.
Writer is a powerful online word processor, designed for collaborative work.