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:-
endPoint = "https://projectsapi.zoho.com/restapi/portal/";
updateTaskParameter = Map();
if(completedDate != null && dueDate != null)
{
delayFieldName = "Score";
daysDiff = daysBetween(toDate(toString(dueDate,format)),toDate(toString(completedDate,format)));
if(daysDiff <= 0)
{
score = 100;
}if(daysDiff > 0 && daysDiff <= 3){score = 70;}if(daysDiff > 3 && daysDiff <= 6){score = 40;}if(daysDiff > 6 && daysDiff <= 9){score = 10;}if(daysDiff > 9){score = 0;}// Get task layout detailstaskLayoutDetailsResponse = invokeurl[url :endPoint + portalId + "/projects/" + projectId + "/tasklayouts"type :GETconnection:"connectionprojects"];sectionDetails = taskLayoutDetailsResponse.get("section_details");for each section in sectionDetails{customFieldDetails = section.get("customfield_details");for each customFieldDetail in customFieldDetails{if(customFieldDetail.get("display_name").containsIgnoreCase(delayFieldName)){delayFieldId = customFieldDetail.get("column_name");break;}}}updateTaskParameter.put("custom_fields",{delayFieldId:score});updateTaskResponse = zoho.projects.update(portalId,projectId,"tasks",taskId,updateTaskParameter,"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.