A custom function is a software code that can be used to automate a process and this allows 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.
Requirement:
Our customer would like to accomplish this specific requirement - when a subtask is added to a main task, Finish-To-Start(FS) dependency should be automatically set between this sub task & the respective parent task.
We had accomplished this requirement using Task Automation - Workflow Rules & Custom Functions.
Create a connection for the Zoho Projects service with the scope “zohoprojects.tasks.ALL” to replace ‘connectionprojects’ with the connection name in the below code. Click this link below to learn how to create the connection. To automate this, we can configure a workflow rule with the trigger as task creation. Refer to the attached screenshots for Arguments & Task Workflow Rule.
Code to be used :
endPoint = "https://projects.zoho.com/restapi/portal/";
// Get Task Details
taskResponse = zoho.projects.getRecordById(portalId,projectId,"Tasks",taskId,"connectionprojects");
if(taskResponse.get("tasks").get(0).containKey("parent_task_id"))
{
parentTaskId = taskResponse.get("tasks").get(0).get("parent_task_id");
dependencyParam = Map();
dependencyParam.put("taskid",taskId);
dependencyParam.put("predids",parentTaskId);
dependencyParam.put("projId",projectId);
dependencyParam.put("toupdate","dependencyset");
dependencyParam.put("childprojId",projectId);
dependencyParam.put("dependencytype","FS");
dependency = invokeurl
[
url :endPoint + portalId + "/projects/" + projectId + "/taskdependency/"
type :POST
parameters:dependencyParam
connection:"connectionprojects"
];
}
return "success";
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.