Kaizen #188 - Building a Timer and Worklog Widget (Part 2)

Kaizen #188 - Building a Timer and Worklog Widget (Part 2)



Welcome back, Tech Wizards!

In Part 1, we developed a Timer Widget that logs active work sessions into the Timer Entries module. 

Now, let's enhance this functionality by transferring these entries into the Work Log subform within the Cases module using a workflow with Deluge function and APIs. We will also explore how to generate insightful reports from the Timer Entries module data.

Here is a consolidated view of the outcomes we aim to achieve through these sequential posts.



The following data model illustrates the modules and subforms involved in this use case to help you understand the structure more clearly.


Learn more about the Data Model and how it helps to simplify the understanding of complex processes.

Auto-Syncing Timer Entries to Case Work Logs

For automating the data transfer from the Timer Entries module to the Work Log subforms within Cases module, we will create a workflow rule with an instant action defined in Deluge function. 

Prerequisites

Create a subform named Work Log in the Cases module with the following fields. 

Field Name
Data Type
Actual Time Taken(in mins.)
Aggregate

(sum of Total Duration (in mins.) field in related case )
End Time
DateTime
Related to Case
Lookup to Cases
Related to Current Case
Checkbox
Start Time
DateTime
Timer Entry
Lookup to Timer Entries
Total Duration
Aggregate 

(sum of all the Total Duration (in mins.) field )
Total Duration (in mins.)
Number
Work Description
Multi Line

Follow the Building a Subform and  Working with Custom Fields help pages for creating the subform and fields in Zoho CRM UI, or you can also make Post Custom Fields API calls to create the custom fields in the subform. 

Step 1: Create a Workflow

  • Login to your Zoho CRM and go to Setup > Automation > Workflow Rules and click Create Rule.
  • Choose the Timer Entries module from the dropdown. Provide name and description for the workflow rule.
  • In the 'When' section of the workflow, choose the trigger as Record Action. In record action, define the trigger as when the End Time field is modified to any value. 
  • In the 'Condition' section, choose all timer entries. In the 'Instant Actions' section, select Function and choose Write your own

Step 2: Create a Deluge Function

  • In the pop box that appeared after choosing to write your own function. Fill in the following details as shown in the image and click Create.
  • A code editor will open, where you have to define the data transfer logic in Deluge. 

Code logic

The UpdateDataInWorkLog function automates the process of syncing a completed Timer Entry with its associated Cases in Zoho CRM by populating the Work_Log subform for each case.

Fetches Target Case Records

The function uses a predefined custom view (cvid) that we created in Part I of this post to retrieve a list of Case records that are eligible for update. It extracts their record IDs and prepares them for bulk processing.

paramMap = Map();
paramMap.put("cvid","5545974000011183885");
getRecordsResponse = invokeurl
[
type :GET
parameters:paramMap
connection:"crm_oauth_connection"
];
responseDataArray = getRecordsResponse.get("data");
idList = List();
for each  item in responseDataArray
{
idList.add(item.get("id"));
}
caseRecordsToUpdate = idList;

Retrieves Timer Entry Details

The selected Timer Entry (identified by recordId received through workflow trigger) is fetched to extract its key details like, Start and end times, Total time spent (duration), Work description, the Case it’s directly related to (if any).

record = zoho.crm.getRecordById("Timer_Entries",recordId,Map(),"crm_oauth_connection");
startTime = record.get("Start_Time");
endTime = record.get("End_Time");
totalTime = record.get("Total_Duration");
workDescription = record.get("Work_Description");
relatedToCaseId = "";
if(record.get("Related_to_Case") != null)
{
relatedToCaseId = record.get("Related_to_Case").get("id");
}

Prepares Work_Log Subform Entries

For each retrieved Case, a new subform entry is created in the Work_Log subform. This entry contains the time details, work description, and a reference to the Timer Entry. A flag (Related_to_Current_Case) marks whether the Timer Entry is directly associated with the Case.

caseRecordIds = caseRecordsToUpdate;
if(!caseRecordIds.isEmpty())
{
recordUpdateArray = List();
for each  caseRecordId in caseRecordIds
{
TimerArray = List();
TimerObj = Map();
TimerObj.put("Work_Description",workDescription);
TimerObj.put("Timer_Entry",recordId);
TimerObj.put("Related_to_Case",relatedToCaseId);
TimerObj.put("Start_Time",startTime);
TimerObj.put("End_Time",endTime);
TimerObj.put("Actual_Duration_in_mins",totalTime.toNumber());
info totalTime;
TimerObj.put("Related_to_Current_Case",caseRecordId == relatedToCaseId);
TimerArray.add(TimerObj);
recordUpdateObj = Map();
recordUpdateObj.put("id",caseRecordId);
recordUpdateObj.put("Work_Log",TimerArray);
recordUpdateArray.add(recordUpdateObj);
}

Bulk Updates Case Records

All Case records are updated in bulk via the Update Records API. Each gets its Work_Log subform updated or appended with the latest Timer Entry details.

updateRequestBody = {"data":recordUpdateArray};
updateResponse = invokeurl
[
type :PUT
parameters:updateRequestBody + ""
connection:"crm_oauth_connection"
];
}

Once done, click Save and associate the merge field (Timer Entry ID) with the function.


This workflow is triggered when the timer widget is stopped and the end time is updated in the corresponding timer entry record. 

Following is a GIF that illustrates how the data sync reflects in the case records.

Generating Reports from Timer Entries

With the Timer Entries and Work Log data in place, you can create comprehensive reports to analyze work patterns, SLA adherence, and productivity trends.
  1. Navigate to the Reports module and click Create Report.
  2. Choose Cases as the primary module and include the Work Log subform.
  3. Select the desired fields like Case Subject, Start Time, End Time, Total Duration, and Work Description. 
  4. Group data by fields like Case Owner or Status to gain insights into workload distribution and case progress.
  5. Apply filters as needed, such as date ranges or specific case statuses.

Refer to the Understanding and Building Report help page for more details. 

With the Timer Widget, automated data transfer to Work Logs, and insightful reporting, we have established a robust system to track and analyze multiple active work times within Zoho CRM.

If you have specific scenarios or challenges you'd like us to address in future Kaizen posts, feel free to share them in the comments or reach out to us at support@zohocrm.com.

Cheers!

------------------------------------------------------------------------------------------------------------------

Additional Reading 

------------------------------------------------------------------------------------------------------------------


      • Sticky Posts

      • Kaizen #197: Frequently Asked Questions on GraphQL APIs

        🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
      • Kaizen #198: Using Client Script for Custom Validation in Blueprint

        Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
      • Celebrating 200 posts of Kaizen! Share your ideas for the milestone post

        Hello Developers, We launched the Kaizen series in 2019 to share helpful content to support your Zoho CRM development journey. Staying true to its spirit—Kaizen Series: Continuous Improvement for Developer Experience—we've shared everything from FAQs
      • Kaizen #193: Creating different fields in Zoho CRM through API

        🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
      • Client Script | Update - Introducing Commands in Client Script!

        Have you ever wished you could trigger Client Script from contexts other than just the supported pages and events? Have you ever wanted to leverage the advantage of Client Script at your finger tip? Discover the power of Client Script - Commands! Commands

        • Recent Topics

        • Customer members area

          Does FSM support a customer members area? If not what do you propose we use if we want the data used in FSM for customers to give them an area / login to see past orders, create new orders and general announcements.
        • Zoho Books-Accounting on the Go Series!

          Dear users, Continuing in the spirit of our 'Function Fridays' series, where we've been sharing custom function scripts to automate your back office operations, we're thrilled to introduce our latest initiative – the 'Zoho Books-Accounting on the Go Series'.
        • Desktop app doesn't support notecards created on Android

          Hi, Does anybody have same problem? Some of last notecards created on Android app (v. 6.6) doesn't show in desktop app (v. 3.5.5). I see these note cards but whith they appear with exclamation mark in yellow triangle (see screenshot) and when I try to
        • Notes created in mobile can no longer be accessed in desktop

          Working with a 2013 Mac running OS 10.14.6; Desktop Notebook version 4.5.3. Using Motorola Moto G Power 5G - 2024; Android app version 6.7 I have been using Notebook for some years. Starting several weeks ago, the notes newly created ion the phone can
        • Function #49: Manage varying installment payments using Zoho Books

          . Hello everyone, and welcome back to our series! Last week, we discussed automating the collection of fixed installment payments in Zoho Books. But what if your payment structure involves charging varying percentages of the invoice total as installments?
        • Open Sans Font in Zoho Books is not Open Sans.

          Font choice in customising PDF Templates is very limited, we cannot upload custom fonts, and to make things worse, the font names are not accurate. I selected Open Sans, and thought the system was bugging, but no, Open Sans is not Open Sans. The real
        • Zoho Writer - Option to Export as .zdoc format

          I've noticed that it's not possible to export a Zoho Writer Document in the .zdoc format. Isn't zdoc, Zoho Writer's own format? My use case is that I sometimes need to create quite complex documents with floating elements, which sometimes need to become
        • Is it possible for contacts to "Re-enter" a workflow in Zoho Campaign?

          We are currently working on a way to automatically add users to from one list to other lists based on specific criteria, but can't seem to find a native way of doing this so we are trying to use Workflows to do this. So, for example, if a user's status is set to "Active," then they should be added to the list "Active Users." If the same user's status is then set to "Paused," they should be added to the list "Paused Users" and removed from the list "Active Users." This works fine for the first go
        • Bulk upload images and specifications to products

          Hi, Many users have asked this over the years and I am also asking the same. Is there any way in which we can bulk upload product (variant) images and product specifications. The current way to upload/select image for every variant is too cumbersome.
        • Out of Office for Just One of My Alias Email

          Can I set up the Out of Office Reply for Just One of my Alias Email Addresses?
        • Can I map multiple Surveys into the CRM using the same fields?

          Hello, We are a healthcare practice that offers two distinct services (Nutrition and Primary Care). We use Zoho Survey for our lead generation form (Get Started Survey), which allows people to express interest in one of the two services and even allows
        • Dealing with API responses where integers have more than 16 digits

          Hi there How do I deal with an api response contaning an int or float with more than 16 digits (before any decimal places for a float). I constantly receive the response "Unable to cast the 'BigInteger' value into a 'BIGINT' value because the input is
        • To Zoho customers and partners: how do you use Linked Workspaces?

          Hello, I'm exploring how we can set up and use Linked Workspaces and would like to hear from customers and partners about your use cases and experience with them. I have a Zoho ticket open, because my workspace creation fails. In the meantime, how is
        • Can't change form's original name in URL

          Hi all, I have been duplicating + editing forms for jobs regarding the same department to maintain formatting + styling. The issue I've not run into is because I've duplicated it from an existing form, the URL doesn't seem to want to update with the new
        • Need Inactive accounts to be visible in Reports in Zoho Books

          I N=need Inactive accounts to be visible in Reports in Zoho Books to do recons of the accounts but when i see the same they are not visible in the Accountant - Account Transactions report
        • unblock e-mail

          please unblock my e-mails info@meatnews.gr and myrtokaterini@meatnews.gr
        • Add Zoho Mail for users who do not need Zoho One

          We have licenses for ZOho One for teams that need to use the suite of products that Zoho One offers.  We have 8 more people who only need email access and we would like to add just a Zoho Mail.  They do not need the Zoho One license.  We are currently
        • Zoho Projects - Q2 Updates | 2025

          Hello Users, With this year's second quarter behind us, Zoho Projects is marching towards expanding its usability with a user-centered, more collaborative, customizable, and automated attribute. But before we chart out plans for what’s next, it’s worth
        • ZML vs HTML Snippet - which is better?

          Are there certain use cases where one is better than the other?
        • Auto CheckOut Based On Shift.

          This Deluge script runs on a scheduled basis to automatically set the 'Actual_Check_Out' time for employees who haven't manually checked out. If the current time is past their scheduled 'Shift_End_Time', the script updates the check-out time to match
        • How to remove some users in zoho accounts

          How to remove some users in Zoho accounts.
        • Customizing Form Questions per Recipient Group in Zoho Campaigns/Forms

          Hello everyone, I would like to ask if it’s possible in Zoho Campaigns or Zoho Forms to send out a campaign where the form questions can be customized based on the group of recipients. Use case example: I have prepared 20 questionnaire questions. For
        • Infinite loop of account verification

          Hi I can't do anything on my zoho account.  I always get this message Hi Sheriffo Ceesay As a security measure, you need to link your phone number with this account and verify it to proceed further. When ever I supply the details, it displays that the number is associated with another account. I don't have any other account on zoho so this is really annoying. 
        • Load PO_Date field (Purchase Order) with current date in Deluge

          Hi, I'm not a full time developer, just helping to customize our CRM, in the small company I work for. There must be something wrong with me, because I can't do something so simple as complete a field with the current date in a function using Deluge.
        • Zoho CRM in Microsoft Power Automate Custom Connector

          Hi everyone, I’m building a Power Automate flow that integrates Microsoft Bookings with Zoho CRM. The goal is to automatically create a meeting (event) in Zoho CRM whenever a new appointment is booked via Microsoft Bookings. To achieve this, I created
        • Spell check sucks

          Come on guys, it's 2024 and your spell check is completely retarded. You gotta fix it.
        • How to include total km for multiple trips in expense report.

          Whenever I create a mileage report it only shows the total dollar amount to be reimbursed. The mileage for each individual trip is included but I also need to see the total distance for all trips in a report? How do I do this?
        • Outgoing blocked: Unusual activity detected.

          I just made payment for my Zohomail Today and have been debited so i will like to be Unblocked because this is what it says (Outgoing blocked: Unusual activity detected) Thank you i await your swift responses
        • Zoho One Login Issue - Unable to receive OTP

          Hi Support Team, I am experiencing a unique login issue with Zoho One. I am attempting to log in from India using Zoho Login credentials provided by a USA-based client. Their Zoho account is hosted on a US data center. After entering the username and
        • Question Regarding Managing Sale Items in Zoho Books

          Good day, I was wondering about something. Right now, Zoho Books doesn’t seem to have a way to flag certain items as being on sale. For example, if I want a list of specific items to be on sale from October 1 to October 12, the user would have to export
        • In the Zoho Creator Customer Payment form i Have customer field on select of the field Data want to fetch from the invoice from based on the customer name In the Customer Payment form i Have subf

          In the Zoho Creator Customer Payment form i Have customer field on select of the field Data want to fetch from the invoice from based on the customer name In the Customer Payment form i Have subform update Invoice , there i have date field,Invoice number
        • Problem of Import Client Users From CRM and or Expense

          I am premium plan user on Projects. I have about 500 customers on Expense and CRM that integrated with each other. According to at below link, I am trying to import clients from CRM, system not allowed to select any customer. If I import from Expense,
        • Unable to see free plan option

          Hello Zoho Support Team, I hope you are doing well. I am trying to sign up for Zoho Mail, but I am unable to see the option for the free plan. Could you please guide me on how I can access or activate the free plan? Thank you for your assistance.
        • unblock my zoho mail account. outlines@zoho.com

          please unblock my zoho mail account, outlines@zoho.com
        • domain not verified error

          Hi when i try to upload a video from zoho creator widget to zoho work drive iam getting domain not verified error.I don't know what to do .In zoho api console this is my home page url https://creatorapp.zoho.com/ and this is my redirect url:www.google.com.Iam
        • equest to Disassociate Bigin from Zoho One and Migrate to Standalone (Upgrade to Bigin Premier – 3 Seats, Annual)

          Dear Zoho One Support Team, I’m writing to request your assistance to disassociate (remove) the Bigin application from our Zoho One organization while preserving all existing Bigin data. After the disconnection is successfully completed, we intend to
        • SMTP email sending problem

          Hello, I've sent emails before, but you haven't responded. Please respond. My work is being disrupted. I can't send emails via SMTP. Initially, there were no problems, but now I'm constantly receiving 550 bounce errors. I can't use the service I paid
        • billing

          hi, I am being billed $12/year, and I can't remember why. My User ID is 691273115 Thanks for your help, --Kitty Pearl
        • How to add receipts

          How to add receipts
        • Unable to enable tax checkboxes

          Hi Zoho Commerce Support, I'm writing to report an issue I'm having with the tax settings in my Zoho Commerce store. I've created several tax rates under Settings > Taxes, but all of them appear with the checkbox disabled. When I try to enable a checkbox,
        • Next Page