Power of Automation :: Unique Task & Issue Prefix Format and Sequencing Rule

Power of Automation :: Unique Task & Issue Prefix Format and Sequencing Rule

Hello Everyone,


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. 


Below is the use case ::

Each project should have its own unique TASK and Issue prefix ID. Every new project must include a sequential number in the prefix—for example, the first project would use ZOHO-PR1, the second ZOHO-PR2 and so on.

This functionality can be implemented using Custom Functions. First, establish a connection with the Zoho Projects service using the scopes 'ZohoProjects.Projects.ALL'.

Make sure to set the connection link name to ‘connectionprojects’ in the code provided below. The screenshot of Arguments is attached for reference.
projectsAPIEndPoint = "https://projectsapi.zoho.com/restapi";
params = Map();
params.put("sort_column","created_time");
params.put("sort_order","descending");
getAllProjects = invokeurl
[
url :projectsAPIEndPoint + "/portal/" + portalId + "/projects/"
type :GET
parameters:params
connection:"connectionprojects"
];
previousProjectPrefix = getAllProjects.get("projects").get(1).get("taskbug_prefix");
if(previousProjectPrefix.contains(prefix))
{
if(previousProjectPrefix.length() == prefix.length())
{
newPrefix = prefix + "1";
}
if(previousProjectPrefix.length() > prefix.length())
{
iterator = previousProjectPrefix.subString(prefix.length()).toLong() + 1;
newPrefix = prefix + iterator;
}
}
else
{
newPrefix = prefix + "1";
}
params = Map();
params.put("taskbugprefix",newPrefix);
updateProject = invokeurl
[
url :projectsAPIEndPoint + "/portal/" + portalId + "/projects/" + projectId + "/"
type :POST
parameters:params
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.