Tip 22: How to allow employees to check in and out, and then automatically calculate their total work hours

Tip 22: How to allow employees to check in and out, and then automatically calculate their total work hours



Hi everyone,

Keeping accurate track of employee hours is crucial to smoothly running business. So this week, we wanted to go over how you can automate this whole process using Zoho Creator. With this tip, you'll learn how to set up a page that will make it easy for your employees to check in and out, and help you track their work hours on a daily basis.

To do this, let's create a sample application called Attendance App, and show you how you can use it to track the total work hours of each of your employees.

Application flow
  • Employees can check in and out by simply clicking on a button
  • Once the employee checks out, the total working hours will be calculated and updated in the admin report
  • Managers and administrators can then monitor the total work hours of each employee on a daily basis 
To do this, we need to create the following components:
  • Attendance form used to record the check in and check out times
  • Dashboard with check in and check out buttons, and two reports
  • A way for users to be given access to the application
  • A report for employees to view their check-in and check-out times
  • A report where the admin can view the details of all employees


Step 1: Create the attendance form

First, we need to create the attendance form to record the times. This form can be hidden, as the check-ins and check-outs are automatically recorded by clicking on the buttons on the page. 



Fields on the attendance form:
  • Email (Email field)
  • Check-in time (Date-Time field)
  • Check-out time (Date-Time field)
  • Total time (Single line field)
  • Status (Drop down field)
Step 2: Create functions for the check in and check out buttons

Now, let's create the two functions we need to record the check-in and check-out times. All you need to do is go to Workflows, click New Functions, and add some code snippets.

Function 1: To record the check-in time

The Check In button on the page calls a function, which adds a record to the attendance form. Use the below code to create the checkintime function:

  1. void login.checkintime()
  2. {
  3. fet = Attendance_form[Check_in_time == today &&Email == zoho.loginuserid]; 
  4. // This condition is to prevent an employee from checking in multiple times on the same day.
  5. if(fet.count() == 0)
  6. {
  7. new = insert into Attendance_form
  8. [
  9. Added_User=zoho.loginuser
  10. Email=zoho.loginuserid
  11. Check_in_time=zoho.currenttime
  12. Status="Checked In"
  13. ];
  14. } .
  15. // This adds a record in the attendance form, which captures the logged-in employee's email and the current time, and sets the status as "Checked In".
  16. openUrl("https://app.zohocreator.com/ownername/attendance-app/report-embed/User_report?zc_SecHeader=false&Email=" + zoho.loginuserid,"iframe","zohoview");
  17. // OpenURL will help you refresh the user-based report (embedded in the page) to display only the login-based entries.
  18. }

Function 2: To record the check-out time

Now, let's create a function that helps us record the check-out time. The Check Out button captures the check-out time, fetches the record containing the check-in time of the corresponding user, and calculates the total working time, which is the difference between the check-out and check-in times in the hours:minutes format.

  1. void login.checkouttime()
  2. {
  3. fet = Attendance_form[Check_in_time == today && Check_out_time == null && Email == zoho.loginuserid];

  4. //This condition checks the record based on the logged-in user and today's date, which has the check-out time as null. It avoids multiple check-outs and ensures the record is added by the corresponding user.

  5. if(fet.ID > 0)
  6. {
  7. fet.Check_out_time=zoho.currenttime;
  8. mil_sec = (fet.Check_out_time - fet.Check_in_time);
  9. actual_minutes = mil_sec / (1000 * 60);
  10. //1000 -> mill sec to sec, 60 -> sec to min
  11. mins = actual_minutes.toLong() % 60;
  12. // % 60 -> Exclude Hours
  13. hours = (actual_minutes / 60).toLong();
  14. // 60 -> min to hour, % 24 (optional) -> Exclude Days
  15. time_string = hours + " : " + mins;
  16. fet.Total_time=time_string;
  17. fet.Status="Checked Out";
  18. }
  19. else
  20. {
  21. // This part handles cases where the user checks in for a night shift, and by the time they check out, the date will have changed. In this case, we use zoho.currentdate.subDay(1) to get the previous date's record. This will be executed only if there isn't any matching record for today's date.
  22. fet1 = Attendance_form[Check_in_time == zoho.currentdate.subDay(1) && Check_out_time == null && Email == zoho.loginuserid];
  23. if(fet1.ID > 0)
  24. {
  25. fet1.Check_out_time=zoho.currenttime;
  26. mil_sec = (fet1.Check_out_time - fet1.Check_in_time);
  27. actual_minutes = mil_sec / (1000 * 60);
  28. //1000 -> mill sec to sec, 60 -> sec to min
  29. mins = actual_minutes.toLong() % 60;
  30. // % 60 -> Exclude Hours
  31. hours = (actual_minutes / 60).toLong();
  32. // 60 -> min to hour, % 24 (optional) -> Exclude Days
  33. time_string = hours + " : " + mins;
  34. fet1.Total_time=time_string;
  35. fet1.Status="Checked Out";
  36. }
  37. }
  38. openUrl("https://app.zohocreator.com/<workspaceName>/attendance-app/report-embed/User_report?zc_SecHeader=false&Email=" + zoho.loginuserid,"iframe","zohoview");

  39. // And this code refreshes the user-based report on the page to display the filtered login-based record with the updated check-out time and the total time.



Step 3: Add the buttons to the dashboard and link them to the functions


Once you've created both functions, you need to create two buttons—Check In and Check Out—on your dashboard, and link the function to these buttons. When a user clicks on them the function is executed and the time is captured.

To do that follow these steps: 
  1. Go to the page builder.
  2. Drag and drop a button onto the page builder, and you'll see a new window appear, where you can add other elements.
  3. Choose the Action type you want to perform—in this case, Execute function.
  4. Choose the function that needs to be executed (refer to the screenshot below). 
  5. Create both buttons and repeat these steps. 



Step 4: Add the reports to the dashboard Admin dashboard:

To track employee working hours This dashboard will help the admin keep track of employee work hours. Apart from the two buttons on the page, there are two reports, which are embedded using an HTML snippet.
  • The list report will dynamically display records based on the logged-in user (for example: if Employee A is logged in, they can only view their own times).
  • The Kanban report will list all the users who've checked in on that day, and it can only be viewed by the admins of the application. 
Now let's embed these two reports on the dashboard. To do that, we need to drag and drop the HTML snippet onto the page builder and write the script below:




  1. <%
  2. {
  3. a = "https://app.zohocreator.com/ownername/attendance-app/report-embed/User_report?zc_SecHeader=false&Email=" + zoho.loginuserid;
  4. %>
  5. <iframe name='zohoview' height='400' width='100%' frameborder='0' scrolling='Auto' src='<%=a%>'></iframe>
  6. <%
  7. if(zoho.loginuserid == zoho.adminuserid)
  8. {
  9. %>
  10. <div elName='zc-component' viewLinkName='Admin' params='zc_Header=true'>
  11. Loading View...</div>
  12. <%
  13. }
  14. }
  15. %>

In the code above, we're embedding the user report using an iframe, so that the user report (iframe) is automatically refreshed after a user clicks on Check In or Check Out. We've also hidden the secondary header present on the user report by setting up zc_SecHeader=false to prevent users from manually adding or modifying the record from the report. The logged-in user filter can be directly applied on the report, or by using the parameter "Email=" + zoho.loginuserid" in the URL.

The admin report is added using a DIV tag, and is displayed only to the account's super admin using the if condition. if(zoho.loginuserid == zoho.adminuserid)
If required, we can add other non-admin emails using the criteria below to make the admin report available for those particular users: 
if(zoho.loginuserid == zoho.adminuserid || zoho.loginuserid == "nonamdin@gmail.com") 

The admin will also have the option to check out users, in case they forget at the end of their shift.

Admin report

The Kanban report is created using the status field, which is a dropdown field, and you can add the code in On Update of the Status Field.For example, when the admin drags the record from the Check in time column to the Check out time column, the user will be automatically checked out. 

You need to choose Edited for Run when a record is while creating the workflow.




Below is the script you need to write in On Update of the Status Field, so that when the record is dragged and dropped to the Check out time column on the Kanban report, the check-out time will be captured.

  1. if(input.Status == "Checked Out" && input.Check_out_time == null)
  2. {
  3. input.Check_out_time = zoho.currenttime;
  4. mil_sec = (input.Check_out_time - input.Check_in_time);
  5. actual_minutes = mil_sec / (1000 * 60);
  6. //1000 -> mill sec to sec, 60 -> sec to min
  7. mins = actual_minutes.toLong() % 60;
  8. // % 60 -> Exclude Hours
  9. hours = (actual_minutes / 60).toLong();
  10. // 60 -> min to hour, % 24 (optional) -> Exclude Days
  11. time_string = hours + " : " + mins;
  12. input.Total_time = time_string;
  13. }
We've also added a filter to the admin report, that will allow the admin to view all the employees who checked in and out for the day. And, if required, you can edit it by week or month, depending on your requirements.



Note: We will soon roll out the hoursBetween function, which can be used to find the difference between the check in and check out times. This function will return the difference of hours between the given start and end date-time values.

We hope this tip was useful for you! If you have any questions, feel free to ask in the comments below, and we'll be happy to address them for you!




























    Access your files securely from anywhere

          Zoho Developer Community




                                    Zoho Desk Resources

                                    • Desk Community Learning Series


                                    • Digest


                                    • Functions


                                    • Meetups


                                    • Kbase


                                    • Resources


                                    • Glossary


                                    • Desk Marketplace


                                    • MVP Corner


                                    • Word of the Day



                                        Zoho Marketing Automation


                                                Manage your brands on social media



                                                      Zoho TeamInbox Resources

                                                        Zoho DataPrep Resources



                                                          Zoho CRM Plus Resources

                                                            Zoho Books Resources


                                                              Zoho Subscriptions Resources

                                                                Zoho Projects Resources


                                                                  Zoho Sprints Resources


                                                                    Qntrl Resources


                                                                      Zoho Creator Resources



                                                                          Zoho Campaigns 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

                                                                                                  • How to Record Loan with interest

                                                                                                    I have received loans from friend he give me like 2 loans so far one is one year repayment and one short, how to properly record his payment, and repayment and give him statement  for each loan he give me 
                                                                                                  • Task status - completed - other options

                                                                                                    I have a dumb question I know i can make custom statuses for the tasks - but is there anyway to make additional "completed" statuses like for instance if i have a task "call back customer" and i leave a vm for them to call back marking it "completed -
                                                                                                  • Task module and related-to field

                                                                                                    In modules other than the Task Module I can add several lookup fields to provide a variety of relationships. In the Task module lookup fields are not available. There is only one "related to" field which I want to use for Company. But I want to relate
                                                                                                  • Zoho Assist "Agree and Download" Button "Greyed Out" ("Light Blued" Out)

                                                                                                    Anyone else having issue where support clients are unable to click "Agree and Download" to access the client so that we can provide remote support? This is for "on demand" support via accessing the support page and entering the support key and name. This
                                                                                                  • Add Lookup Field in Tasks Module

                                                                                                    Hello, I have a need to add a Lookup field in addition to the ones that are already there in the Tasks module. I've seen this thread and so understand that the reason lookup fields may not be part of it is that there are already links to the tables (https://help.zoho.com/portal/en/community/topic/custom-fields-on-task-module).
                                                                                                  • migrating from Zoho Invoices (CRM) to Zoho Books

                                                                                                    Good day, I was wondering if there was a easy way to migrate all the quotes and invoices from Zoho Invoices CRM to Zoho Books. We plan to move to using Zoho Books in a few weeks and would like to have all the quotes and invoices from the past 3 years
                                                                                                  • Zoho MA and Custom Module

                                                                                                    I am trying to create a sync between Markting Automation and Zoho CRM. I am mapping a custom module from the CRM. The custom module has email field mobile phone field However I cannot finish the integration since the system keeps asking me for email or
                                                                                                  • When is partial reimbursement going to be launched?

                                                                                                    Hi there. I saw somewhere that the partial reimbursement feature is in the work. What is the update and ETA of that? Our clients and prospects have been asking us and we agree that that is an important feature to have.
                                                                                                  • All notes disappeared

                                                                                                    I've been using the notebook app for over five years on my phone without being logged into an account. A few days ago I opened the app and all my notes had disappeared. Since then I tried restarting my phone, updating the app and logging into my account,
                                                                                                  • Introducing Keyboard Shortcuts for Zoho CRM

                                                                                                    Dear Customers, We're happy to introduce keyboard shortcuts for Zoho CRM features! Until now, you might have been navigating to modules manually using the mouse, and at times, it could be tedious, especially when you had to search for specific modules
                                                                                                  • Year-End Wrap: Declutter Your Inbox Using Email Filters

                                                                                                    Ping!—an email drops in. And another. And another! It's finally that time of the year when your inbox will be bursting with messages from team members, clients, and marketing agents, leaving you feeling overwhelmed and distracted. Sounds familiar? Now
                                                                                                  • Unified Notes View For Seamless Collaboration

                                                                                                    To facilitate better coordination among different departments and team members, the notes added to a record can now be accessed in all its associated records. With this, team members, from customer service representatives to field technicians, can easily
                                                                                                  • Q4 Europe In-person Zoho User Group Meetup: Streamlining Your Business Processes & Introduction to Zoho CRM for Everyone

                                                                                                    Hello Zoho Community, We are excited to announce our upcoming Zoho User Group meetup in Europe! This session is designed to help you streamline your business processes using Zoho CRM, with a special focus on enhancing customer interactions and leveraging
                                                                                                  • Formula fields - Request for dynamic recalculation / proper implementation

                                                                                                    Hi Guys, I have a big problem with Zoho formula fields. They don't recalculate each time the record is viewed - only when a record is edited. Formula fields should be updated dynamically each time a record is retrieved. As an example: I have a formula
                                                                                                  • Items attribute questions

                                                                                                    Many of my items have attributes, such as size and color. How can I add new fields to the "New Items" screen to capture that in my Purchase Orders, Items, and Sales Order pages? I only see these attribute fields when adding an Item Group. Also, on the
                                                                                                  • Organize and Track Phases with Phase Custom Views

                                                                                                    Phase Custom Views let you filter and display phases based on specific criteria. This helps you focus on what’s most relevant for you and your team. Filter phases using criteria such as budget, status, and more. Share views with specific users or teams
                                                                                                  • Record Asset Received as Payment

                                                                                                    How exactly would you account for this in books? For example, I receive a mini computer for a review and I get to keep it after the video is published. Would debit my normal asset account (e.g. Computers) and credit an income account (e.g. Other Income).
                                                                                                  • Invoice Line Item Report

                                                                                                    Is it possible to run an 'Invoice Line Item Report'? The 'Invoice Details Report' shows one row per invoice. I would like one row per Invoice Line Item.
                                                                                                  • Transform Your Customer Support with AI-Powered Chatbots in Zoho SalesIQ

                                                                                                    Ever wondered how some companies seem to have superhuman customer support? Let's uncover their secret! In the digital age, customer expectations are skyrocketing. Did you know that according to McKinsey, 75% of consumers expect a response within five
                                                                                                  • Unused items should not count into the available number of custom fields

                                                                                                    Hey, I realized that unused Items reduce the number of available custom fields. I can't see a case where that makes sense. Especially in our case where we have two different layouts in Deals with a lot of different fields, this causes problems.
                                                                                                  • Power of Automation :: Automatically start / pause / stop timer on task status update.

                                                                                                    Hello Everyone, A Custom function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it. Requirement:-
                                                                                                  • Progressive Invoicing

                                                                                                    Progressing invoicing is needed for many industries. It would be great to see it implemented into Zoho Books as well. Set up and send progress invoices in QuickBooks Desktop (intuit.com)
                                                                                                  • Client Script - mapping data from different module

                                                                                                    Dear ZOHO Team Firstly I need to describe the need - I need to have data from Contacts module based on lookup field - the 5 map limit is not enough for me because I have almost 20 fields to copy So I have decided to make a Customer Script - and from unknown
                                                                                                  • Using Queries with dynamic parameters in Kiosk Studio

                                                                                                    Hi, I'm pretty new when it comes to developing within Zoho (I'm really a .NET developer), as it was just added to my responsibilities. For a new feature in the CRM, I'm trying to develop a Kiosk function to show a list of records (retrieved by the new
                                                                                                  • DORA compliance

                                                                                                    For DORA (Digital Operational Resilience Act) compliance, I’ll want to check if Zoho provides specific features or policies aligned with DORA requirements, particularly for managing ICT risk, incident reporting, and ensuring operational resilience in
                                                                                                  • Files Uploaded to Zoho WorkDrive Not Being Indexed by Search Engines

                                                                                                    Hello, I have noticed that the files I upload to Zoho WorkDrive are not being indexed by search engines, including Google. I’d like to understand why this might be happening and what steps I can take to resolve it. Here are the details of my issue: File
                                                                                                  • Zoho Creator Upcoming Updates - December 2024

                                                                                                    Hi all, We're excited to be back with the latest updates and developments on the Creator platform. Here's what we're going over this month: Deluge AI assistance Rapid error messages in Deluge editor QR code & barcode generator Expandable RTF and multi
                                                                                                  • Customer can't comment on SO or Invoice

                                                                                                    Hi I just saw that my customers are not able to submit a comment either on invoices or sales order. What happens if my customer hits submit is just nothing. only a red line appears on top of the page which probalby indicates an error. I'm not able to
                                                                                                  • Zoho Creator customer portal limitation | Zoho One

                                                                                                    I'm asking you all for any feedback as to the logic or reasoning behind drastically limiting portal users when Zoho already meters based on number of records. I'm a single-seat, Zoho One Enterprise license holder. If my portal users are going to add records, wouldn't that increase revenue for Zoho as that is how Creator is monetized? Why limit my customer portal to only THREE external users when more users would equate to more records being entered into the database?!? (See help ticket reply below.)
                                                                                                  • See Calendar When Creating Meetings On Record Page

                                                                                                    It would be a great user experience to see you calendar while you are creating a meeting on a record page. Here is how I imagine it could look:
                                                                                                  • Power of Automation: Automatically send an email to all portal users with today's list of Open tasks.

                                                                                                    Hello Everyone, A Custom Function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as to when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it. Requirement:-
                                                                                                  • Introduction of Robotics Process Automation in Zoho products

                                                                                                    It will be great if Zoho can start advancing from automation to robotics process automation. For a start, it can be started with smart document understanding. Provide OCR engines Google cloud, Microsoft Azure Computer vision OCR, Microsoft OCR, Omnipage
                                                                                                  • Lock a custom field on a deal record but keep all other fields editable?

                                                                                                    I have a custom field, which auto-populates a job number upon converting a lead to a deal but the automation breaks if someone accidentally edits that field. I want to lock that field but keep all other fields open. Is this possible? I've tried through
                                                                                                  • how to create a new line in string in Client Script?

                                                                                                    I want to show an alert using client script, I need to add a new line in String, I assume I can use \n\n inside a string, but unfortunately it doesnt work ZDK.Client.showAlert("First Line \n\nI expect this is in second line");
                                                                                                  • Add Feature To Hide Plugin Sections On Record View

                                                                                                    Hi team, I'm trying to help a client tidy up their CRM. When it comes to record view some sections and fields are visible no matter what Layout Rules are applies and they are not removeable from the layout editor. I would like to see an option to hide
                                                                                                  • Creator Simplified #10: Predefine Form Field Values and Make Them Read-Only for Users

                                                                                                    Hey Creators, Ready for this week's tip in the Creator Simplified series? Today, we will explore how to have read only fields in a form. Use Case: Assume a scenario where the default value for a Department field needs to be English Literature, but you
                                                                                                  • Problem configuring/customizing sales pipeline steps

                                                                                                    Hello, I have created several sales pipelines with different stages in them. Unfortunately I forgot to properly configure these steps (conversion probability, forecast category). How can I modify and customize all these steps? Thnak you by advance M
                                                                                                  • fetch records from analytics table from creator

                                                                                                    I have a creator workflow that I am working in that will compare data from within the app to a table in zoho analytics. Is there a way to fetch a record from Analytics? I have attempted a custom connector with analytics and tried to use it with invoke
                                                                                                  • Directly Edit, Filter, and Sort Subforms on the Details Page

                                                                                                    Hello everyone, As you know, subforms allow you to associate multiple line items with a single record, greatly enhancing your data organization. For example, a sales order subform neatly lists all products, their quantities, amounts, and other relevant
                                                                                                  • Ability to Change Custom View After Cadence Creation

                                                                                                    Dear Zoho Team, I hope you are well. We would like to request an enhancement to the Cadence feature in Zoho CRM. Currently, during the creation of a Cadence, we can select a Custom View under the "Who is this for?" section. However, once the Cadence is
                                                                                                  • Next Page