Hello Everyone,
A Custom function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it.
Requirement:-
One of our customers wants the status of a completed project to change to "In Progress" when a new task is created in that project. The same can be implemented using Task custom functions along with Workflow rules in Zoho Projects.
Below is the custom function code for reference.
Custom function code:-
//TODO: Please create a connection for the Zoho Projects service with the scopes
scopes: ZohoProjects.Projects.ALL,ZohoProjects.Tasks.ALL
Click this link below to learn how to create the connection.
getProjectDetails = invokeurl
[
url :endPoint + portalId + "/projects/" + projectId + "/"
type :GET
connection:"xxxxxx"
];
layoutId = getProjectDetails.get("projects").get(0).get("layout_details").get("project").get("id");
getProjectLayoutDetails = invokeurl
[
url :endPoint + portalId + "/module/projects/layouts/" + layoutId + "/?module=Projects&moduleId=0"
type :GET
connection:"xxxxxx"
];
for each customstatus in getProjectLayoutDetails.get("customstatus")
{
if(customstatus.get("status_name").containsIgnoreCase("In Progress"))
{
customStatusId = customstatus.get("status_id");
break;
}
}
if(customStatusId != null)
{
projectsParameter = Map();
projectsCustomStatusId = customStatusId;
projectsParameter.put("custom_status",projectsCustomStatusId);
updateProjectResponse = invokeurl
[
url :endPoint + portalId + "/projects/" + projectId + "/"
type :POST
parameters:projectsParameter
connection:"xxxxxx"
];
}
return "success";
Make sure to replace xxxxxx with the Zoho Projects connections link name. Screenshot of the list of parameters to be mapped and sample Task workflow rule is attached for reference.
We hope you found this post useful. If you have any questions or wondering if your requirement could be met using custom functions, feel free to share them in the comments section below.