Power of Automation:: Automate the process of creating checklist upon task creation.

Power of Automation:: Automate the process of creating checklist upon task creation.

Hello Everyone,

A Custom Function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as to when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it.

Requirement:-

One of our customers wanted to add a specific checklist from the checklist template upon Task creation. This was successfully implemented using Task custom function in Zoho Projects. Please refer this link to know more about checklist extension. 
 
Custom function code:-
 

// extension > settings > url id = app_id
// scopes: ZohoProjects.entity_properties.ALL and ZohoProjects.extension_properties.ALL
endPoint = "https://projects.zoho.com/restapi/portal/";

checklistName = "checklist name";
// replace with your checklist name
appId = "YYYYY";
// replace with your app id
getAllChecklist = invokeurl
[
url :endPoint + portalId + "/extensions/properties/retrieve?app_id=" + appId + "&property_key=templatesTitle"
type :GET
connection:"XXXXX"
];
values = getAllChecklist.get("properties").get(0).get("value").toCollection();
for each value in values
{
if(value.get("value").containsIgnoreCase(checklistName))
{
templateId = value.get("template_id");
}
}
getParticularChecklist = invokeurl
[
url :endPoint + portalId + "/extensions/properties/retrieve?app_id=" + appId + "&property_key=" + templateId
type :GET
connection:"XXXXX"
];
values = getParticularChecklist.get("properties").get(0).get("value").toCollection();
childObject = Map();
childObject.put("ListID",templateId);
childObject.put("value",checklistName);
childObject.put("view","fullView");
childObject.put("templateId",templateId);
childArray = List();
childArray.add(childObject);
object = Map();
object.put("Checklist_Titles_Store",childArray);
object.put("count",1);
parentArray = List();
parentArray.add(object);
param = Map();
param.put("app_id",appId);
param.put("entity_id",taskId);
param.put("entity_type","1");
param.put("project_id",projectId);
param.put("property",parentArray);
storeInEntity = invokeurl
[
url :endPoint + portalId + "/entity/properties/store"
type :POST
parameters:param
connection:"XXXXX"
];
param.clear();
childArray.clear();
for each value in values
{
childObject = Map();
childObject.put("completed","false");
childObject.put("who","");
childObject.put("time","");
childObject.put("id",value.get("id"));
childObject.put("title",templateId);
childObject.put("value",value.get("value"));
childArray.add(childObject);
}
object.clear();
object.put("Checklist_Items_Store",childArray);
parentArray.clear();
parentArray.add(object);
param.put("app_id",appId);
param.put("entity_id",taskId);
param.put("entity_type","1");
param.put("project_id",projectId);
param.put("property",parentArray);
storeInEntity = invokeurl
[
url :endPoint + portalId + "/entity/properties/store"
type :POST
parameters:param
connection:"XXXXX"
];
return "success";

 
 
Ensure that XXXXX  in the above code is replaced with the Zoho OAuth connection link name, including the scope ZohoProjects.entity_properties.ALL and ZohoProjects.extension_properties.ALL. Refer to this link for guidance on creating the connection.
 
Additionally, replace YYYYY with the checklist app ID and checklist name in line 4. A sample screenshot is attached for reference on fetching the app ID.
 
Please find the screenshots of the parameters to be mapped and sample Task workflow rules.

We hope you found this post useful. If you have any questions, feel free to share them in the comments below.