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 

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

    Access your files securely from anywhere







                            Zoho Developer Community





                                                  Use cases

                                                  Make the most of Zoho Desk with the use cases.

                                                   
                                                    

                                                  eBooks

                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                   
                                                    

                                                  Videos

                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                   
                                                    

                                                  Webinar

                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                   
                                                    
                                                  • Desk Community Learning Series


                                                  • Meetups


                                                  • Ask the Experts


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner




                                                            • 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


                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner






                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources


                                                                                              Zoho Writer Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ








                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方




                                                                                                            • Recent Topics

                                                                                                            • Collective-booking event not added to all staff calendars

                                                                                                              We assign two staff to certain events. When the client books this event, it adds it to one staff calendar (the 'organiser') but not the other. How can I ensure all staff assigned to a collective booking get the event in their calendar? (A side note: it
                                                                                                            • Issue showing too many consultations in my workspace link.

                                                                                                              Hi Team, I’ve set up two Workspaces to track meetings from different sources. So far, this has been working well, and the two Workspaces are differentiated without any issues. However, when I navigate to Consultations and share the link to my personal
                                                                                                            • ZOHO Android Client

                                                                                                              Hi, I installed the Android app, but it had an issue, so I reinstalled it. I was able to add multiple accounts, but now when I add the next account, it just duplicates the one I already have and will not even allow me to enter the info for another account.
                                                                                                            • I'd like to suggest a feature enhancement for SalesIQ that would greatly improve the user experience across different channels.

                                                                                                              Hello Zoho Team, Current Limitation: When I enable the pre-chat form under Brands > Flow Controls to collect the visitor’s name and email, it gets applied globally across all channels, including WhatsApp, Messenger, and Instagram. This doesn't quite align
                                                                                                            • Enhance Barcode/QR Code scanner with bulk scanning or continuously scanning

                                                                                                              Dear Zoho Creator, As we all know, after each scan, the scanning frame closes. Imagine having 100 items; we would need to tap 100 times and wait roughly 1 second each time for the scanning frame to reopen on mobile web. It's not just about wasting time;
                                                                                                            • Is there a way to sync Tags between CRM and Campaigns/Marketing Hub?

                                                                                                              I wonder if there is a way to synch the tags between CRM and Marketing-Hub / Campaigns?
                                                                                                            • Non-depreciating fixed asset

                                                                                                              Hi! There are non-depreciable fixed assets (e.g. land). It would be very useful to be able to create a new type of fixed asset (within the fixed assets module) with a ‘No depreciation’ depreciation method. There is always the option of recording land
                                                                                                            • Managing Rental Sales in Zoho Inventory

                                                                                                              I am aware that Zoho Inventory is not yet set up to handle rental sales and invoicing. Is anyone using it for rentals anyway? I'd like to hear about how others have found work arounds to manage inventory of rental equipment, rental payments, etc. Th
                                                                                                            • Megamenu

                                                                                                              Finally! Megamenu's are now available in Zoho-Sites, after waiting for it and requesting it for years! BUT ... why am I asked to upgrade in order to use a megamenu? First: Zoho promised to always provide premium versions and options for all included Zoho-applications
                                                                                                            • Cannot access KB within Help Center

                                                                                                              Im working with my boss to customize our knowledge base, but for some reason I can see the KB tab, and see the KB categories, but I cannot access the articles within the KB. We have been troubleshooting for weeks, and we have all permissions set up, customers
                                                                                                            • Zoho Flow to Creator 3001 Respoonse

                                                                                                              I have updated my Flows with the new V2 connection to Zoho Creator, but now some Flows do not work. They take in data from a Webhook and are supposed to create a record in Creator, however creator returns a 3001 message along with a failure, but I cannot
                                                                                                            • File Upload to Work Drive While Adding Records in Zoho Creator Application

                                                                                                              Hi I am trying to set a file attachment field in zoho creator form, to enable the user to upload a scanned document from their local pc. The file should be uploaded to zoho workdrive and not to the default zoho creator storage. The file link should be
                                                                                                            • Zoho Creator to Zoho CRM Images

                                                                                                              Right now, I am trying to setup a Notes form within Zoho Creator. This Notes will note the Note section under Accounts > Selected Account. Right now, I use Zoho Flow to push the notes and it works just fine, with text only. Images do not get sent (there
                                                                                                            • COQL order by COUNT not working

                                                                                                              Dear community, I am trying to get a list of deal amounts per planner working on it and sorted to get see who has the least amount of deals. For some reason, I am unable to use sort by in combination with a COUNT. My original code was: query = "select
                                                                                                            • Why not possible to generate?

                                                                                                              Using this https://desk.zoho.com/DeskAPIDocument#TicketCount#TicketCount_Getticketcountbyfield on my ZML script url :"https://desk.zoho.com/api/v1/ticketsCountByFieldValues?departmentId=XXXXXXXXXXX&accountId!=XXXXXXXXX&customField1=cf_country_1:XXXXXX&field=overDue"
                                                                                                            • email

                                                                                                              Hi My crm email is not working, can you check, I have zoho one account.
                                                                                                            • Need option to see Mass Emails & Cadences in Gmail Outbox OR a dedicated Zoho Outbox

                                                                                                              Hi everyone, Right now, when we send 1:1 emails from gmail (with gmail API connected to Zoho CRM), those emails appear both in gmail's sent folder and in Zoho CRM. That works well. But when we send Mass Emails or Cadence emails form Zoho CRM, they are
                                                                                                            • Integración Books para cumplir la ley Crea y Crece y Ley Antifraude (VeriFactu)

                                                                                                              Hola: En principio, en julio de 2025, entra en vigor la ley Crea y Crece y Ley Antifraude (VeriFactu). ¿Sabéis si Zoho va a cumplir con la ley para cumplir con la facturación electrónica conectada a Hacienda? Gracias
                                                                                                            • I can't found API for Sales Receipts

                                                                                                              Hello May you please help me to find an API document for Sales Receipts to get data and retrive a custom fields like Invoice and credit notes Regards
                                                                                                            • Problem with reports due to "Connected" items change

                                                                                                              Now that the change has been made to use "connected" items I can no longer run the reporting I need in CRM. I should be able to start with Deals as the parent, connect down to the Account (Account_Name) on the deal as the child, then to any child items
                                                                                                            • Kaizen #205 - Answering Your Questions | Managing Picklists and Enabling History Tracking via Zoho CRM APIs

                                                                                                              Hello everyone! Welcome back to another post in our Kaizen series. In this post, we will look at how you can manage picklist fields in Zoho CRM using APIs. This topic was raised as feedback to Kaizen #200, so we are taking it up here with more details.
                                                                                                            • Custom Fonts in Zoho CRM Template Builder

                                                                                                              Hi, I am currently creating a new template for our quotes using the Zoho CRM template builder. However, I noticed that there is no option to add custom fonts to the template builder. It would greatly enhance the flexibility and branding capabilities if
                                                                                                            • Internally created tickets

                                                                                                              Hi there When tickets are created internally on-behalf of customers - there is nothing to show that the ticket was created by an internal agent. This means, that it's easy for our agents to confuse tickets which were created by internal team members and
                                                                                                            • Spilt Axis for stacked column and line graph

                                                                                                              Each month around this time I prepare a business review deck. One of the biggest annoyances I have with Zoho, also happens to be something that most other platforms have provided for a long time now, and that is being able to create a chart with stacked
                                                                                                            • Automatically change website passwords

                                                                                                              Hi everyone, We just switched to a Professional package to also use the "Automatically change website passwords" function. But I cannot find anything about it, how to use it, anywhere. Does anyone know how I can use this function? Best, Caspar
                                                                                                            • Zoho Desk Integration - Add the option to send the estimate from the Zoho Desk Ticket Integration

                                                                                                              Hi, Currently in the Zoho Desk integration, the user is able to create an estimate from a ticket, once the estimate is created the user can see the estimate under the ticket (see screenshot below), but is not able to send that estimate from Zoho Desk.
                                                                                                            • Change Invoice Prices for an Effective Date

                                                                                                              Hi, It would be a really good feature to be able to change the prices on invoices/recurring invoices from an effective date in the event of price increases. For instance, I am in the process of increasing prices that will be effective from a specific
                                                                                                            • "Other Current Asset" accounts as "Paid Through" accounts in Expense

                                                                                                              It would be incredibly useful to be able to assign accounts of type Other Current Asset as Paid Through accounts in Expense. Currently, Other Current Liability are permitted as Paid Through Accounts. This makes sense, as Credit Cards are current liabilities.
                                                                                                            • Multi column open text questions that allows respondents to add rows for additional information

                                                                                                              I need to create a question that has 2 columns with open text, but I also need to allow respondents to click a "+" button, or something similar, so that they can add additional information if they choose to. I've tried using the Multiple Textboxes type
                                                                                                            • Bot Filtering & Apple Mail Privacy Protection Compliance in Zoho Campaigns

                                                                                                              Dear Campaigns Users, The wait is over! We’re excited to announce that the enhanced bot filtering feature is now live in Zoho Campaigns. This update brings greater accuracy to your email campaign reports by distinguishing real user engagement from automated
                                                                                                            • Découvrons les détails qui simplifient vos journées de travail avec Trident

                                                                                                              Nous nous installons dans des routines efficaces et rodées avec le temps. Chaque matin, nous ouvrons nos e-mails, passons aux messages, consultons notre agenda, puis attaquons nos tâches. Ce processus nous semble maîtrisé, mais est-il réellement optimisé
                                                                                                            • No option for pick up in Zoho Books / Inventory but yes on commerce

                                                                                                              Is it planned to release soon on books/inventory?
                                                                                                            • Issue with Purchase Rate Showing as “0” After Importing Items List

                                                                                                              Dear Zoho Books Support Team, Good day. I’m reaching out regarding an issue I’m facing while importing my items list into Zoho Books. Despite mapping all fields correctly and including the purchase price for each product in my Excel file, the Purchase
                                                                                                            • API for Task Entity in Zoho Books

                                                                                                              I’m working on automating task creation in Zoho Books via a custom button in the Bills Module. The goal is to create a task in the Tasks Module and assign it to the Finance Team, so they can track progress efficiently. While reviewing Zoho Books documentation,
                                                                                                            • create invoice in zoho books from the zoho forms

                                                                                                              Is there a native way to have create invoice in zoho books, when zoho form is completed?
                                                                                                            • Email undelivered

                                                                                                              GOod Day I am always receiving an uncategorized-bounce to my email. I am not sure why this is happening.
                                                                                                            • Custom Buttons for Mass Actions

                                                                                                              Hello everyone, We’ve just made Custom Buttons in Zoho Recruit even more powerful! You can now create Bulk Action Buttons that let you perform actions on multiple records at once, directly from the List View. What’s new? Until now, custom buttons were
                                                                                                            • Add inventory_valuation_method to items endpooints

                                                                                                              To ensure consistent item creation it would be helpful to have the inventory_valuation_method (FIFO vs WAC) be able to be set at item creation or as an update (consistent with current behavior where it is not allowed for items with existing transactions)
                                                                                                            • Use Zoho to send sales receipts for Gocardless transactions

                                                                                                              I've been using gocardless for years and have d/d mandates set up on there. Each week we get bulk payments from customer d/d's. However, we need to send sales receipts to these customers. So I know I can sync mandates into Zoho, and then I can set up
                                                                                                            • Zoho - Gocardless sales receipts

                                                                                                              I've been using gocardless for years and have d/d mandates set up on there. Each week we get bulk payments from customer d/d's. However, we need to send sales receipts to these customers. So I know I can sync mandates into Zoho, and then I can set up
                                                                                                            • Next Page