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

    • Automate Timesheet Approvals with Multi-level Approval Rules

      Introducing Approval Rules for Timesheets in Zoho Projects. With this automation, teams can manage how timesheets are reviewed and approved by setting up rules with criteria and assigning approvers to handle submissions. Timesheet, when associated to
    • Accessibility Spotlight Series - 1

      Every user interacts with products differently, what feels intuitive to one may be challenging for another. Addressing this, accessibility is built into Zoho Project's design philosophy. This helps users navigate and perform actions with ease irrespective
    • Customize User Invites with Invitation Templates

      Invitation Templates help streamline the invitation process by allowing users to create customized email formats instead of sending a one-size-fits-all email. Different invitation templates can be created for portal users and client users to align with
    • Zoho Projects - Q3 Updates | 2025

      Hello Users, The final quarter of the year 2025 has begun, and we at Zoho Projects are all set with a plan. New targets to achieve and new milestones to reach, influenced by the lasting imprint of the past quarter. 2025's Q3 saw some new features and
    • Introducing Version-3 APIs - Explore New APIs & Enhancements

      Happy to announce the release of Version 3 (V3) APIs with an easy to use interface, new APIs, and more examples to help you understand and access the APIs better. V3 APIs can be accessed through our new link, where you can explore our complete documentation,