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

        • 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
        • Search on Custom Field

          We're working on an integration with the Zoho FSM API and are trying to retrieve companies based on a custom field we added to the Companies module. However, we can't find a way to filter or query records using custom fields through the API. We have a
        • Import Holiday Calendars

          HI Zoho Is there anyway of importing an online calendar like https://www.calendarlabs.com into the business hours calendars, to speed up setup of holiday calendars. Also could we also request a feature where you can specify a Holiday as hours, i.e it could be that the company is on a 1/2 day due to a holiday or when it is Eid in the UAE and they are only allowed to work restricted hours so we need the calendar to be flexible to allow for this. Regards Jamie
        • 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 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.
        • How to report 'Response violation' OR 'Resolution violation'

          Hi, I want to report on SLA Violation Type. I grouped my tickets on this column. It seems I only get 'Response and Resolution Violation' or 'Not Violated'. The former seems to be given to a ticket if only the Response Time was violated. I would expect
        • 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
        • Zoho Books - France

          L’équipe de Zoho France reçoit régulièrement des questions sur la conformité de ses applications de finances (Zoho Books/ Zoho Invoice) pour le marché français. Voici quelques points pour clarifier la question : Zoho Books est un logiciel de comptabilité
        • 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
        • Age Calculation

          I've attempted to calculate the age of someone based on their birthday input by using the formula field. It works but I don't want all those decimals on there. I then tried to use "set variable" after birthday input but I get a field type mismatch, long vs. floating. Any ideas would be wonderful.
        • 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? 
        • Filtering Tickets based on Email headers

          We're starting to get a lot more junk coming into our Zoho Desk, which is then triggering unnecessary email alerts to agents. Once thing we could do to cut this junk in half, is to filter tickets based on email headers. Any email containing the `List-Unsubscribe`
        • 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
        • Why am I getting event Pop-up Notification for events that have been cancelled?

          Why is Calendar Notification still popping up for events that have been cancelled or changed? Each time events are cancelled or changed, I have observed that I am still getting notifications for them. Below is a sample pop-up notification for one of the
        • Whatsapp Limitation Questions

          Good day, I would like to find out about the functionality or possibility of all the below points within the Zoho/WhatsApp integration. Will WhatsApp buttons ever be possible in the future? Will WhatsApp Re-directs to different users be possible based
        • Create a draft in reply to an email via Emails API

          Hi, I’d like to use the outgoing webhook to automatically create a draft reply to incoming mail. How can I use the Emails API to create a draft reply that is linked to an existing email thread? I couldn’t find the relevant method in the documentation.
        • India Tech Support

          Is there no phone tech support number for India? And no chat facility either?
        • Billing Management: #1 Billing an Universal Business Routine

          Hello, As the saying goes, "Do the hardest job first", we started with the complex subject in finance, revenue management, which is considered to be the backbone for any business. Now, let's shift our focus and take a deep dive into this Billing Management
        • Show/ hide specific field based on user

          Can someone please help me with a client script to achieve the following? I've already tried a couple of different scripts I've found on here (updating to match my details etc...) but none of them seem to work. No errors flagged in the codes, it just
        • What is a a valid JavaScript Domain URI when creating a client-based application using the Zoho API console?

          No idea what this is. Can't see what it is explained anywhere.
        • 5名限定 課題解決型ワークショップイベント Zoho ワークアウト開催のお知らせ (9/25)

          ユーザーの皆さま、こんにちは。Zoho ユーザーコミュニティチームの藤澤です。 9月開催のZoho ワークアウトについてお知らせします。 今回はZoomにて、オンライン開催します。 ▷▷参加登録はこちら:https://us02web.zoom.us/meeting/register/6OSF2Bh6TumsMIlDwaY_PQ ━━━━━━━━━━━━━━━━━━━━━━━━ Zoho ワークアウトとは? Zoho ユーザー同士で交流しながら、サービスに関する疑問や不明点の解消を目的とした「Zoho
        • Zoho Calendar not syncing correctly with personal Google Calendar

          Coming to this forum as Zoho Calendar support team is not responding, any more. For the past 8 weeks, I have been having an issue with Zoho Calendar not syncing with my personal Google Calendar correctly. I subscribed to Zoho Calendar iCal in my personal
        • Introducing Assemblies and Kits in Zoho Inventory

          Hello customers, We’re excited to share a major revamp to Zoho Inventory that brings both clarity and flexibility to your inventory management experience! Presenting Assemblies and Kits We’re thrilled to introduce Assemblies and Kits, which replaces the
        • Next Page