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

        • How to search a value stored in a subform?

          Hello, We store serial numbers in subforms but now we would like to be able to search the values to be able to easily find the record with the serial number. I saw that it's not possible to search such values through global search but is it possible to do it an other way? Thank you,
        • Field Dependency Not Working on Detail Page in Zoho Desk

          Hi Support Team, I’ve created field dependencies between two fields in Zoho Desk, and they are working correctly on the Create and Edit layouts. However, on the Detail page, the fields are not displaying according to the dependencies I’ve set — they appear
        • How do the keyword critera work?

          Hi, I'm working on automated assignment of tickets based on keywords. How does this feature work? Where does this criteria look for keywords - email address, subject, email body? Can you please clarify this as I want to avoid overlapping with criteria
        • Error: Unsupported content type: text/html;charset=UTF-8 after tryeing to get the token for n8n automation

          I am working on ZOHO Desk automation and need to get the ZOHO auth token for n8n I have created the app in ZOHO Desk API, got client id and client secret. Added all data required to get a token in n8n. After I sign in with my ZOHO credentials in ZOHO
        • Improving Collaboration Features in Zoho Portal

          Hello Zoho Community, I’ve recently started exploring Zoho services and I’m really impressed with the wide range of features. However, I feel there is still room for improvement in the collaboration area. For example, it would be really helpful if we
        • Automated Shopify Emails Not Being Delivered

          I have an ecommerce store with Shopify. I recently set up my email to be served through Zoho. Since doing this, customers are not receiving some of our automated emails from Shopify itself. Our initial email that confirms their purchase goes through but our Shipping Notification that is automatically sent out upon fulfillment is not going through. Sometimes we get a notice that it's been classified as spam, sometimes nothing. I can send/receive email via Outlook on my desktop and I can send/receive
        • Clear Tag & Linking Between Quotes and Sales Orders

          Hi Zoho Team, In Zoho Books, when a quote is converted into a sales order, it would be extremely useful to have: A clear tag/indicator on the quote showing that it has been converted into a sales order. A direct link in the sales order back to the originating
        • I can't log in to my account on Thunderbird

          I've just had to rebuild my PC (calamitous mess from Microsoft with Win10/Win 11 'upgrade' - they confirmed I had to start with a new build). I have used Zoho mail for years via Mozilla Thunderbird, but now I've had to download the latest version of TBird,
        • New in Cadences: Option to Resume or Restart follow-ups when re-enrolling records into a Cadence, and specify custom un-enrollment criteria

          Managing follow-ups effectively involves understanding the appropriate timing for reaching out, as well as knowing when to take a break and resume later, or deciding if it's necessary to start the follow-up process anew. With two significant enhancements
        • Send a campaign to one recipient.

          Very often I speak to a customer and they say they didn't see my email (maybe it went in Junk, maybe they deleted it). Anyway, I just want to go into the Campaign and send it to one person. You already have a feature very close to this - when sending a Test. While developing a campaign, I can send tests to anyone. Why can't we have this AFTER  the campaign has been sent? I know, there's a caveat, and that's in the use of merge tags. Most of the time I only use FNAME, but maybe you could check if
        • Try FSM again for our business

          We already have our customers individual equipment in CRM with serial numbers, install dates, warranty length and importantly next service which is generally 2 years. a month before the service date is due we get get a report and send out service reminders.
        • Use Zoho Books to bill for work done in Zoho Desk??

          I'm trying to see if something is possible (and if yes, how). We use Zoho One to manage our business. We have a lot of clients that will put in a ticket (via portal) to have work done. Out techs will pick up the ticket, do the work, and then log the time
        • Get Cliq Meetings in my O365 calendar

          Hi, we are currently evaluating to replace the Teams Messaging and Meetings with Cliq. We currently still have all our email and calendars in O365. What i want to achieve is, to create a (ZOHO) meeting from Cliq and have this meeting added to my Outlook/O365
        • Issue with Zoho Help Portal – Tickets Missing or Not Answered

          Hi, How are you? I think there may be an issue with the Zoho Help Portal. I opened a few tickets directly in the help portal a some time ago but never received any response I also opened ticket 148356451 by email. I did receive a reply to it, but the
        • No bank feeds from First National Bank South Africa since 12 September

          I do not know how Zoho Books expects its customers to run a business like this. I have contacted Zoho books numerous times about this and the say it is solved - on email NO ONE ANSWERS THE SOUTH AFRICAN HELP LINE Come on Zoho Books, you cannot expect
        • Changing the Default Search Criteria for Finding Duplicates

          Hey everyone, is it possible to adjust the default search criteria for finding and merging duplicate records? Right now, CRM uses some (in my opinion nonsensical) fields as search criteria for duplicate records which do nothing except dilute the results.
        • DUNS & Bradstreet and Credit risk monitoring integration with Zoho books

          Small businesses not being paid by bigger clients and clients of all sizes is a huge problem. It will be nice if Zoho develops integration with DUNS & Bradstreet(D&B) and Credit risk monitoring integration with Zoho books. That have small businesses can
        • Zoho Forms - Form Rules based on attachment fields

          Many businesses use forms to collect documents and images from customers. In many cases, you may want to trigger a notification or other automation based on whether or not an attachment was added. I've noticed that attachment fields do not appear in Rules
        • How can I sync from Zoho Projects into an existing Zoho Sprints project?

          Hi I have managed to integrate Zoho Projects with Zoho Sprints and I can see that the integration works as a project was created in Zoho Sprints. But, what I would like to do is to sync into an existing Zoho Sprints project. Is there a way to make that
        • How to sync from Zoho Projects into an existing Sprint in Zoho Sprints?

          Hi I have managed to integrate Zoho Projects with Zoho Sprints and I can see that the integration works as a project was created in Zoho Sprints. But, what I would like to do is to sync into an existing Zoho Sprints project. Is there a way to make that
        • Add multiple users to a task

          When I´m assigning a task it is almost always related to more than one person. Practical situation: When a client request some improvement the related department opens the task with the situation and people related to it as the client itself, the salesman
        • Add QUOTE OWNER profile image to a Quote Template

          I can add their email address.. phone number, DOB. I need to add a users profile picture so when they assign a template to a quote they own it adds their picture to the cover page. I've tried hacking a solution together but there has to be an easier way.
        • Can't open draft email for editing

          Last night I started composing an email and I let it save in drafts. This morning I want to continue working on the email. It is in my Drafts folder but it will not open. The only option there is to delete it. This is not the first time it has happened. On previous occasions I have just deleted the draft and started afresh, but I really want this one back. Windows 10 with Pale Moon 28.10.0 browser.
        • Failing to generate Access and Refresh Token

          Hello.  I have two problems: First one when generating Access and Refresh Token I get this response:  As per the guide here : https://www.zoho.com/books/api/v3/#oauth (using server based application) I'm following all the steps. I have managed to get
        • Email Integration - Zoho CRM - OAuth and IMAP

          Hello, We are attempting to integrate our Microsoft 365 email with Zoho CRM. We are using the documentation at Email Configuration for IMAP and POP3 (zoho.com) We use Microsoft 365 and per their recommendations (and requirements) for secure email we have
        • No Response from Zoho Support in 8 Days - Typical?

          I have a couple of issues I'm trying to work through. Initially, I was getting support from support@zohofsm.com, but I have not received a response in 8 days (11 on another question). Is this typical? Can I pay for support? For context, I am not spamming
        • Open filtered deals from campaign

          Do you think a feature like this would be feasible? Say you are seeing campaign "XYZ" in CRM. The campaign has a related list of deals. If you want to see the related deals in a deal view, you should navigate to the Deals module, open the campaign filter,
        • Change scheduling emails time

          When sending an individual email there is a great feature to schedule them to send later. I could only use the one time that is suggested. Is there a way to select another time? Regards, Glenn
        • Zoho CRM: how can I control which contacts to sync with Outlook?

          I was just playing around syncing contacts from Zoho to MS Outlook (MS365 account.) The problem is our firm has hundreds of thousands of contacts and I don't want to bury my contacts list in outlook. Any help with this is greatly appreciated.
        • How to overcome limitations in meetings

          As a company, one of our deliverables is a meeting between two other companies, where we act as facilitators. So, if we recorded this meeting  in Zoho CRM, it should be connected to 2 accounts, 2 contacts, and 1 campaign (a campaign, in our use, is the
        • Different MRP / Pricing for same product but different batches

          We often face the following situations where MRP of a particular product changes on every purchase and hence we have to charge the customer accordingly. This can't be solved by Batch tracking as of now so far as I understand Zoho. How do you manage it as of now? 
        • Add a 'Log a Call' link to three dot icon in Canvas

          Hi, There's a three dot element when creating a canvas called 'More'. I would like to modify this to add a link that says 'Log a Call' in order to quickly record the details of a cellphone call. I'd also like this to be a simple 'contact' selection and
        • Syncing Zoho Forms with Bigin - Embedding issue?

          Hello everyone, I created a Zoho Form for a page on my GoDaddy website to collect leads, which then transfers the data to Bigin. However, I'm facing an issue where it doesn't seem to work properly. I've integrated Zoho Forms with Bigin and tried embedding
        • Can not add fields to a Section

          I feel like I'm missing something obvious: I can add new Sections to my form but I can not add fields to the Sections. I've tried fields already on the form as well as dragging and dropping new fields into the Section but nothing will go into it. What
        • Record Logged in User while using CRM lookup field

          Is it possible, while using the Zoho CRM lookup field, to automatically use the user account logged into Zoho CRM in a hidden field? I was hoping to add employee accounts to my current plan. But would like a record on the Form submission of who submitted
        • Form Rules for Suburb Categories to alternate landing pages or Making a Fields Contents ALL CAPS

          I need to send differentform submissions to two to three different thank-you URLs (for Meta/Google pixels) depending on which suburb a user selects in a form. I have ~400 suburbs split into two categories (A and B, based on business value). Current challenges:
        • Collaps Notes

          There are times when long/large notes are added to a record i.e. Accounts or Deals etc. Currently, the full note is displayed in the notes related list section. It would be great if by default only 5 to 10 rows of the note are displayed when the note
        • Zoho Down

          I have a drop in my Zoho One services.
        • Runing RPA Agents on Headless Windows 11 Machines

          Has anyone tried this? Anything to be aware of regarding screen resolution?
        • Problem for EU users connecting Zoho CRM through Google Ads for Enhanced conversions

          Has anyone else experienced this problem when trying to connect Zoho CRM through Google Ads interface to setup enhanced conversions? Did you guys get it fixed somehow? The Problem: The current Google Ads integration is hardcoded to use Zoho's US authentication
        • Next Page