Power of Automation:: Daily Time log summary broadcast to Zoho Cliq using Schedule Custom Functions

Power of Automation:: Daily Time log summary broadcast to Zoho Cliq using Schedule Custom Functions


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 calculate the total time logs added by each developer at 11:59 PM and post a summary message in a specific Zoho Cliq channel along with the developer's name and email address as shown below. This was accomplished using Schedule Custom Functions.    



Custom function code:
 
/* TODO
*Replace the channel Unique Name (Line 4)
*Replace the email ids i.e user email in the criteria  (Line 8)*/
portalId = "XXXXXX";
channelUniqueName = "testchannelpeq";
userParam = Map();
userParam.put("filter",{"criteria":{{"cfid":"4","criteria_condition":"contains","value":{"user email 1"}},{"cfid":"4","criteria_condition":"contains","value":{"user email 2"}},{"cfid":"4","criteria_condition":"contains","value":{"user email 3"}},{"cfid":"4","criteria_condition":"contains","value":{"user email 4"}},{"cfid":"4","criteria_condition":"contains","value":{"user email 5"}},{"cfid":"4","criteria_condition":"contains","value":{"user email 6"}}},"pattern":"1 OR 2 OR 3 OR 4 OR 5 OR 6"});
getUserInfo = invokeurl
[
url :endPointV3 + portalId + "/users"
type :GET
parameters:userParam
connection:"YYYYYY"
];
// info getUserInfo;
userAndLoghours = List();
for each  user in getUserInfo.get("users")
{
/* Get all time logs*/
moduleTemplate = Map();
moduleTemplate.put("type","task");
timesheetParam = Map();
timesheetParam.put("view_type","day");
timesheetParam.put("module",moduleTemplate);
timesheetParam.put("start_date",zoho.currentdate);
timesheetParam.put("filter",{"criteria":{{"field_name":"user","criteria_condition":"is","value":{user.get("id")}}},"pattern":"1"});
taskTimesheetResponse = invokeurl
[
url :endPointV3 + portalId + "/timesheet"
type :GET
parameters:timesheetParam
connection:"YYYYYY"
];
info taskTimesheetResponse;
if(!taskTimesheetResponse.get("time_logs").isEmpty())
{
log = Map();
log.put("display_name",user.get("display_name"));
log.put("email_id",user.get("email"));
log.put("full_name",user.get("full_name"));
log.put("log_hours",taskTimesheetResponse.get("log_hours").get("total_hours"));
userAndLoghours.add(log);
}
}
/*  Send message to channel*/
if(userAndLoghours.size() > 0)
{
response = Map();
slidesList = list();
slidesList0 = Map();
slidesList0.put("type","table");
slidesList0.put("title","Log hours of developer");
data = Map();
headersList = list();
headersList.add("Developer");
headersList.add("Email");
headersList.add("Logged Hours");
data.put("headers",headersList);
rowsList = list();
for each  details in userAndLoghours
{
rowsList0 = Map();
rowsList0.put("Developer",details.get("full_name"));
rowsList0.put("Email",details.get("email_id"));
rowsList0.put("Logged Hours",details.get("log_hours"));
rowsList.add(rowsList0);
}
data.put("rows",rowsList);
slidesList0.put("data",data);
slidesList.add(slidesList0);
response.put("slides",slidesList);
response.put("text",zoho.currentdate.toString("dd-MMM-yyyy"));
info response;
chat = zoho.cliq.postToChannel(channelUniqueName,response,"YYYYYY");
}
 
Make sure to replace XXXXX with your Portal Id and YYYYYY with Zoho Oauth connection link name along with scopes: ZohoProjects.users.READ, ZohoProjects.timesheets.READ, ZohoCliq.Webhooks.CREATE. Please find the screenshot of the sample Schedule function for reference.

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

    • Sticky Posts

    • Automation Series: Auto-create Dependent Task on Status Change

      In Zoho Projects, you can automatically create and assign a dependent task when a task’s status is updated. This helps teams stay aligned, ensures reviews happen on time, and reduces manual effort. In this post, we’ll walk through an easy setup using
    • Time Log Reminder

      Tracking the time spent on tasks and issues is one of the most important functions of a timesheet. However, users may forget to update the time logs because they have their own goals to achieve. But, time logs must be updated at regular intervals to keep
    • Introducing the Zoho Projects Learning Space

      Every product has its learning curve, and sometimes having a guided path makes the learning experience smoother. With that goal, we introduce a dedicated learning space for Zoho Projects, a platform where you can explore lessons, learn at your own pace,
    • Update on V2 API End-of-Life Timeline

      Dear Users, Earlier this year, we shared the launch of the V3 APIs and requested users to migrate from the older V2 APIs by December 2025. We have received valuable feedback from our users and partners regarding their migration timelines. We are happy
    • Automation Series: Auto-update Phase Status

      Hello Folks! You can auto-update your phase's status based on status of underlying tasks using custom functions. In this series, we will showcase how to create and run custom functions, using Deluge, with ease. Follow the steps below and automate your