Power of Automation::Streamline log hours to work hours upon task completion.

Power of Automation::Streamline log hours to work hours upon task completion.

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:-

One of our customers wanted to update the work hours value same as log hours upon task completion. For example, if the work hours value is 8 and the log hours value is 5, then work hours should also be updated to 5 when the status of the Task is updated as closed. This ensures accurate user allocation, allowing the remaining available time to be assigned to other tasks. This was successfully implemented using Task custom functions in Zoho Projects.

Custom function code:-
 
getLogHours = invokeurl
[
url :endPoint + portalId + "/projects/" + projectId + "/tasks/" + taskId + "/logs/"
type :GET
connection:"XXXXXXX"
];
hours = getLogHours.get("timelogs").get("tasklogs");
logMap = Map();
for each  logHours in hours
{
// info "logs : " + logHours.get("hours_display") + " owner_id : " + logHours.get("owner_id");
if(logMap.containsKey(logHours.get("owner_id"))) {
prev = logHours.get("hours_display").toList(":");
curr = logMap.get(logHours.get("owner_id")).toList(":");
sumFirst = prev.get(0).toLong()+curr.get(0).toLong();
sumSec = prev.get(1).toLong()+curr.get(1).toLong();
if(sumSec >= 60) {
sumFirst = sumFirst+(sumSec/60).round(0);
sumSec = sumSec-(sumSec/60).round(0)*60;
}
// info "sumFirst : "+sumFirst+" sumSec : "+sumSec;
logMap.put(logHours.get("owner_id"),sumFirst.toString()+":"+sumSec.toString());
} else {
logMap.put(logHours.get("owner_id"),logHours.get("hours_display"));
}
}
// info logMap;
taskResponse = zoho.projects.getRecordById(portalId,projectId,"Tasks",taskId,"XXXXXXX");
owners = taskResponse.get("tasks").get(0).get("details").get("owners");
// info owners;
taskWorks = List();
ownerIds = "";
for each  owner in owners
{
if(owner.get("name").containsIgnoreCase("Unassigned"))
{
break;
}
else
{
isOwnerPresent = true;
ownerId = owner.get("id");
ownerWorkHours = logMap.get(ownerId);
taskWork = Map();
taskWork.put("user_id",ownerId);
taskWork.put("working_hours",ownerWorkHours);
taskWorks.add(taskWork);
ownerIds = ownerIds + owner.get("id") + ",";
// info ownerWorkHours;
}
}
taskOwners = ownerIds.removeLastOccurence(",");
// info taskOwners;
updateTaskParameter = Map();
if(isOwnerPresent)
{
updateTaskParameter.put("owner_work",taskWorks);
updateTaskParameter.put("work_type","work_hours");
updateTaskParameter.put("person_responsible",taskOwners);
updateTaskResponse = zoho.projects.update(portalId,projectId,"tasks",taskId,updateTaskParameter,"XXXXXXX");
info updateTaskResponse;
}
return "success";


Make sure to replace XXXXX with the Zoho Projects connection link name along with scopes ZohoProjects.portals.READ, ZohoProjects.tasks.ALL, ZohoProjects.timesheets.READ. Check this link to learn how to create the connection. 

Please find the screenshot of the parameters to be mapped and sample Task workflow rules. We hope you found this post useful. If you have any questions, feel free to share them in the comments below.

      Zoho Campaigns Resources


        • Desk Community Learning Series


        • Digest


        • Functions


        • Meetups


        • Kbase


        • Resources


        • Glossary


        • Desk Marketplace


        • MVP Corner


        • Word of the Day


        • Ask the Experts


          • Sticky Posts

          • Set Custom Business Calendars and Holidays for Global Teams

            Managing a project across diverse teams means accounting for more than just tasks and deadlines; it means acknowledging how and when each team actually works. Users might follow different working days or observe region-specific holidays that cannot be
          • Introducing Version-3 APIs - Explore New APIs & Enhancements

            Happy to announce the release of Version 3 (V3) APIs with an easy to use interface, new APIs, and more examples to help you understand and access the APIs better. V3 APIs can be accessed through our new link, where you can explore our complete documentation,
          • Restore Trashed Records Anytime Within 30 Days

            Access the recycle bin from the Data Administration tab under the settings page in Zoho Projects, which gives better control over the trashed data. When records like projects, phases, task lists, tasks, issues, or project templates are trashed, they are
          • Organize and Clone Task Custom Views

            We have rolled out two new enhancements to task custom views: Custom View Groups and Custom View Clone. Custom View Groups Similar to predefined view groups, we have introduced groups for custom views to help organize and categorize them. My Custom Views:
          • Flexible Milestone Invoicing

            If your Zoho Projects portal is integrated with Zoho Invoice/Books, you can now create an invoice for your milestones. You can enable it under Integration Preference and invoice milestones regardless of the project's billing type. For instance, consider

          Zoho CRM Plus Resources

            Zoho Books Resources


              Zoho Subscriptions Resources

                Zoho Projects Resources


                  Zoho Sprints Resources


                    Zoho Orchestly Resources


                      Zoho Creator Resources


                        Zoho WorkDrive Resources



                          Zoho CRM Resources

                          • CRM Community Learning Series

                            CRM Community Learning Series


                          • Tips

                            Tips

                          • Functions

                            Functions

                          • Meetups

                            Meetups

                          • Kbase

                            Kbase

                          • Resources

                            Resources

                          • Digest

                            Digest

                          • CRM Marketplace

                            CRM Marketplace

                          • MVP Corner

                            MVP Corner




                            Zoho Writer Writer

                            Get Started. Write Away!

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

                              Zoho CRM コンテンツ








                                ご検討中の方

                                  • Recent Topics

                                  • Windows Desktop App - request to add minimization/startup options

                                    Support Team, Can you submit the following request to your development team? Here is what would be optimal in my opinion from UX perspective: 1) In the "Application Menu", add a menu item to Exit the app, as well as an alt-key shortcut for these menus
                                  • Function 56: Automatically enable the option for customers to pay via bank account

                                    Hello everyone and welcome back to our series! One of the key features of Zoho Books is its integration with multiple payment gateways, allowing you to receive online payments for your invoices. This ensures faster payments, automates payment tracking
                                  • Attach Files to Your Notecards and share them on the go!

                                    Hey everyone! We’re excited to share a feature many of you have been asking for — you can now attach files directly to your text notecards and share with ease! 🙌 This update was built with your feedback in mind, especially for those who wanted a simple
                                  • Can i connect 2 instagram accounts to 1 brand?

                                    Can i connect 2 instagram accounts to 1 brand? Or Do i need to create 2 brands for that? also under what subscription package will this apply?
                                  • Workdrive on Android - Gallery Photo Backups

                                    Hello, Is there any way of backing up the photos on my android phone directly to a specific folder on Workdrive? Assuming i have the workdrive app installed on the phone in question. Emma
                                  • 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
                                  • YouTube Live #1: AI-powered agreement management with Zia and Zoho Sign

                                    Hi there! We're excited to announce Zoho Sign’s first YouTube live series, where you can catch the latest updates and interact with our Zoho Sign experts, pose questions, and discover lesser-known features. We're starting off by riding the AI wave in
                                  • Mass Mail Statistics - Number of unsent emails

                                    How do I find out which emails were not sent?
                                  • How to add a % Growth column for year-over-year comparison (2024 vs 2025)

                                    Hello, I am trying to build a monthly revenue comparison between 2024 and 2025 in Zoho CRM Analytics. My current setup is: Module: Deals (Affaires) Filter: Stage = Closed Won Date field: Closing Date Grouping: By Month Metrics: Sum of Amount for 2024,
                                  • How to searchByCriteria records that are under approval?

                                    I need to search for both approved and pending approval records Is that possible with this method? Or I need to a different method? var priceReqID = $Page.record_id; log(priceReqID); var records = ZDK.Apps.CRM.Price_List_Item.searchByCriteria("Price_Request:equals:"
                                  • Power of Automation::Streamline log hours to work hours upon task completion.

                                    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:-
                                  • How to add Simple Analytics to Zoho Pages?

                                    I have a website with Zoho Pages, how do I add Simple Analytics on it? They seem to have code they need to be embedded https://docs.simpleanalytics.com/script
                                  • Product details removed during update from other system

                                    We maintain our product details in an other system. These details are synchronized with Zoho at the end of each day, through an API. This has worked perfectly sofar. But last Monday, all product codes and some other product data have been wiped during
                                  • End Date in Zoho Bookings

                                    When I give my appointments a 30 minutes time I would expect the software not to even show the End Time.  But it actually makes the user pick an End Time.  Did I just miss a setting?  
                                  • I hate the new user UI with the bar on the left

                                    How can I reverse this?
                                  • Cant seem to delete an email account

                                    Hello, I have researching for 4 days how to delete an email account and I am absolutely without a clue. The email account I am trying to delete is support<AT>fyshoes<dot>com. It's the first email account I made and it (is???) was associated with the super user (me). I have since changed it to adming<AT>fychoes<dot>com and I see the support email in my list but I just cant seem to get rid of it. Ultimately I want to associate that email account with another user that I want to add. This is really
                                  • Commerce Order as Invoice instead of Sales Order?

                                    I need a purchase made on my Commerce Site to result in an Invoice for services instead of a Sales Order that will be pushed to Books. My customers don't pay until I after I add some details to their transaction. Can I change the settings to make this
                                  • Sync desktop folders instantly with WorkDrive TrueSync (Beta)

                                    Keeping your important files backed up and accessible has never been easier! With WorkDrive desktop app (TrueSync), you can now automatically sync specific desktop folders to WorkDrive Web, ensuring seamless, real-time updates across devices. Important:
                                  • Script that deletes a record?

                                    We're using WP Plugin "Integration for WooCommerce and Zoho Pro", and have created a couple of Feeds to send data to Zoho. We are trying to create Contact records, but only based upon condition. Tried to make it with small Deluge function and Workflow,
                                  • Introducing Profile Summary: Faster Candidate Insights with Zia

                                    We’re excited to launch Profile Summary, a powerful new feature in Zoho Recruit that transforms how you review candidate profiles. What used to take minutes of resume scanning can now be assessed in seconds—thanks to Zia. A Quick Example Say you’re hiring
                                  • Import data into Multi-Select lookup field from CSV/Excel

                                    How to import data into a multi-select lookup field from the CSV/Excel Sheet? Let's say I have an Accounts multi-select lookup field in the Deals module and I want to import the Deals with Accounts field. Steps:- 1. Create/edit a multi-select lookup field
                                  • Auto Capitalize First Letter of Words

                                    Hi I am completely new to ZOHO and am trying to build a database. How can i make it when a address is entered into a form field like this: main st it automatically changes is to show: Main St Thank You
                                  • A formula that capitalises the first letter of each word

                                    Hi all, is there a zoho formula that can capitalise the first letter of each word in a string? INITCAP only capitalises the first letter of the first word.
                                  • Add Analytics function for Title case (capitalising each word in a string)

                                    At present, you can only capitalise each word in a string in Analytics during data import. It would be really useful to be able to do this with a formula column, but there is no Title Case function.
                                  • Office 365 and CRM mail integration: permission required

                                    Has anyone run into this weird problem? My email server is Office 365. When I try to configure Zoho CRM to use this server, a Microsoft popup window opens requesting user and password. After entering that, I get a message in the Microsoft window saying
                                  • Updating Subform Record from other Form

                                    Just wanted to ask how to properly approach this. I have 2 forms and would like to trigger an auto update on the subform once record submitted. block below only updates 1 row for each recordRow in input.AV_System { AssetRecord = Site_Asset_Services[SOR_No
                                  • How to conditionally embed an own internal widget with parameters in an html snippet?

                                    Hello everyone, I'm trying to create a dynamic view in a page using an HTML snippet. The goal is to display different content based on a URL parameter (input.step). I have successfully managed to conditionally display different forms using the following
                                  • Reverse payment on accidentally closed invoice.

                                    An invoice was closed accidentally with the full payment added. However, only partial payment was paid. How can I reopen the invoice and reverse this to update it to show partial payment?
                                  • Quotes in Commerce?

                                    In Zoho Ecommerce, I need to be able to generate quotes, negotiate with customers, and then generate invoices. Currently, I plan to integrate Zoho CRM to generate quotes. After negotiation and confirmation, I will push the details to Zoho Ecommerce to
                                  • Zoho Commerce - Mobile Application

                                    Does Zoho Commerce have a mobile application for customers to place an order?
                                  • Adding Markdown text using Zoho Desk API into the Knowledge Base

                                    Hi Zoho Community members, We currently maintain the documentation of out company in its website. This documentation is written in markdown text format and we would like to add it in Zoho Knowledge Base. Do you know if there is REST API functionality
                                  • Register user through Phone Number by Generating OTP

                                    In zoho commerce , I am developing website on online food store Inilialy the user get verification code to their email for registering there account for login. But I need to login using phone number by generating OTP automatically rather than verification
                                  • 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
                                  • Super Admin Access to All Courses and Spaces in Zoho Learn

                                    Dear Zoho Learn Team, We hope this message finds you well. We are using Zoho Learn extensively for internal and agent training. While managing our courses and spaces, we encountered a significant limitation regarding admin access and course management.
                                  • Zoho Vault Passwords

                                    Is there a way to consume Zoho Vault Manager passwords using the API? Thanks in advance.
                                  • Is the ChatGPT Assistant integration capable of recognizing WhatsApp voice messages?

                                    I was wondering: if a visitor sends me a voice message on WhatsApp, would the assistant be able to transcribe it and reply to them?
                                  • 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
                                  • 【Zoho CRM】レポート機能のアップデート

                                    ユーザーの皆さま、こんにちは。コミュニティチームの藤澤です。 今回は「Zoho CRM アップデート情報」の中から、レポート機能のアップデートをご紹介します。 目次 1. レポートのエクスポート時のレコードIDの表示について 2. 通貨項目の表示について 3. レポートの削除の監査ログへの反映について 1. レポートのエクスポート時のレコードIDの表示について これまで、レポートをエクスポートするとファイルにレコードIDが必ず含まれていました。レコードIDが識別子として役立つ場合もありますが、実際には多くの企業で参照されることはありません。
                                  • Translation in zoho bookings

                                    We cant translate zoho booking emails. The general text we can change. But what about text like: ""Here a link to join the meeting online:"" and "Add to Zoho Calendar" and "Add to Google Calendar"? No professional business have mixed languages. Its looking
                                  • Help Center IFrame Issue

                                    I have had a working Help Center on my website using an iframe for a while. But now for some reason the sign in page gets a refused to connect error. Can someone please help. If I go to the url manually it works correclty
                                  • Next Page