A custom function is a software code that can be used to automate a process and this allow you to automate a notification, call a webhook, or perform logic immediately after a workflow rule is triggered. This feature helps to automate complex tasks and calculations.
Let's take the below User Requirement -
In the Issues module, when Affected Milestone field is updated, a new task should be created and linked to that issue automatically. Also, the task should be created only if there are no tasks linked with the bug.
The code below will help you to achieve the above requirement.
Note:: Please refer to this post to access custom function feature within Zoho Projects.
// TODO: Please create a connection for the Zoho Projects service with the scopes "ZohoProjects.task.ALL, ZohoProjects.Bugs.ALL". Replace 'xxxxxxxxx' with the connection name. Click this link below to learn how to create the connection.
endPoint = "https://projectsapi.zoho.com/restapi/portal/";
endPointV3 = "https://projectsapi.zoho.com/api/v3/portal/";
portalId = "680386201";
connectionName = "connectionprojects";
taskIds = List();
// get associated task
associatedBugResponse = invokeurl
[
url :endPointV3 + portalId + "/projects/" + projectId + "/bugs/" + issueId + "/associated-tasks"
type :GET
connection:connectionName
];
if(associatedBugResponse.get("associated_tasks").size() == 0)
{
// create a task
createTaskParam = Map();
createTaskParam.put("name",taskName);
createTaskParam.put("person_responsible",ownerZPUID);
createTaskResponse = invokeurl
[
url :endPoint + portalId + "/projects/" + projectId + "/tasks/"
type :POST
parameters:createTaskParam
connection:connectionName
];
taskId = createTaskResponse.get("tasks").get(0).get("id_string");
taskIds.add(taskId);
// associate task
associateBugParam = Map();
associateBugParam.put("task_ids",taskIds);
associateBugResponse = invokeurl
[
url :endPointV3 + portalId + "/projects/" + projectId + "/bugs/" + issueId + "/associate-tasks"
type :POST
parameters:associateBugParam
connection:connectionName
];
}
Creating custom functions in Zoho Projects is straightforward and well-documented. Zoho provides a range of built-in functions that you can use as a starting point, and you can also easily define your own functions using Zoho's scripting language, Deluge. Give it a try and see how it can save your time and boost your productivity!
Watch this space for more such custom function codes.
Writer is a powerful online word processor, designed for collaborative work.