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.
Requirement:-
When a user is tagged in the description of a task, the respective user should be immediately notified via email. This has been accomplished using the features 'Custom Functions' & 'Workflow Rules'
endPointV3 = "https://projectsapi.zoho.com/api/v3/portal/";
alphaRemovedComments = removeAllAlpha(taskDescription);
inNumber = false;
numbers = List();
currentNumber = "";
// task description
for each el in alphaRemovedComments.toList("")
{
if(el.equals("#"))
{
currentNumber = "";
inNumber = true;
}
else if(el.equals("]"))
{
if(inNumber && currentNumber != "")
{
numbers.add(currentNumber);
}
inNumber = false;
}
else if(inNumber)
{
currentNumber = currentNumber + el;
}
}
for each userId in numbers
{
usersDetails = invokeurl
[
url :endPointV3 + portalId + "/projects/" + projectId + "/users/" + userId
type :GET
connection:"connectionprojects"
];
emailId = usersDetails.get("email");
sendmail
[
from :zoho.loginuserid
to :emailId
subject :"You are mentioned in task description of task " + taskNumber
message :taskDescription
]
}
return "success";