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 would like to start / pause / stop the the timer based on below status update for the Task.
Task status - In Progress - Start the timer.
Task status - hold - Pause the timer.
Task status - closed - Stop the timer.
Above requirement can be implemented using Task custom functions along with Workflow rules in Zoho Projects.
Custom function code:-
// TODO: Please create a connection for the Zoho Projects service with the scopes scopes: ZohoProjects.tasks.ALL,ZohoProjects.Timesheet.ALL
Click this link below to learn how to create the connection.
endPoint = "https://projectsapi.zoho.com/restapi/portal/";
if(equalsIgnoreCase(statusValue,"In progress"))
{
startTimerResponse = invokeurl
[
url :endPoint + portalId + "/projects/" + projectId + "/tasks/" + taskId + "/timer/?action=start"
type :POST
connection:"xxxxxx"
];
}
if(equalsIgnoreCase(statusValue,"hold"))
{
pauseTimerResponse = invokeurl
[
url :endPoint + portalId + "/projects/" + projectId + "/tasks/" + taskId + "/timer/?action=pause"
type :POST
connection:"xxxxxx"
];
}
if(equalsIgnoreCase(statusValue,"closed"))
{
stopTimerResponse = invokeurl
[
url :endPoint + portalId + "/projects/" + projectId + "/tasks/" + taskId + "/timer/?action=stop&approver=" + actionperformerId
type :POST
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.