Power of Automation :: Automatically divide the work hours between the task owners

Power of Automation :: Automatically divide the work hours between the task owners

Hello Everyone,

A custom function is a software code that can be used to automate a process and this allows you to automate a notification, call a webhook, or perform logic immediately after a workflow rule is triggered. This feature helps to automate complex tasks and calculations. 

Let us consider the below use case from a customer - 

As per the design, Work hours will be allocated based on the number of owners assigned to a task. For example, A task is added with the duration of 16 hours and assigned to a user, John. So, the work hours allotted for him will be 16 hours. If one more owner is added to the same task, the work hours gets doubled and the total work hours will be 32. 

But we have received a specific use case from a customer and he wanted to allocate the work hours at task level instead of individual user level.

From the above scenario, he wants the work hours '16' to be equally divided between the task owners rather than doubling it to 32.

We resolved this use case using Custom functions in Zoho Projects

Todo : Create a connection for Zoho Projects service with the scopes “ZohoProjects.portals.READ”, “ZohoProjects.tasks.READ”, “ZohoProjects.tasks.UPDATE” to replace ‘connectionprojects’ with the connection name. Click this link below to learn how to create the connection. Attached the screenshots of Task Workflow Rule & Arguments.

Script to be used : 
  1. endPoint = "https://projects.zoho.com/restapi/portal/";
  2. updateTaskParameter = Map();
  3. ownerIds = "";
  4. isOwnerPresent = false;
  5. taskWorks = List();
  6. if((duration.contains(":")||duration.toNumber()!=0)&&affectedValues.get("action").containsIgnoreCase("Creation"))
  7. {
  8. // Get Task Details
  9. taskResponse = zoho.projects.getRecordById(portalId,projectId,"Tasks",taskId,"connectionprojects");
  10. owners = taskResponse.get("tasks").get(0).get("details").get("owners");
  11. workHours = taskResponse.get("tasks").get(0).get("work");
  12. workhour = workHours.toList(":").get(0).toNumber();
  13. workhour_mins = workHours.toList(":").get(1).toNumber();
  14. convertedMinsToHours = workhour_mins.toNumber() / 60;
  15. totalWorkHours = workhour + convertedMinsToHours;
  16. ownerCount = owners.size();
  17. for each  owner in owners
  18. {
  19. if(owner.get("name").containsIgnoreCase("Unassigned"))
  20. {
  21. break;
  22. }
  23. else
  24. {
  25. isOwnerPresent = true;
  26. ownerWorkHours = totalWorkHours / (ownerCount * ownerCount);
  27. taskWork = Map();
  28. taskWork.put("user_id",owner.get("id"));
  29. taskWork.put("working_hours",ownerWorkHours.round(2));
  30. taskWorks.add(taskWork);
  31. ownerIds = ownerIds + owner.get("id") + ",";
  32. }
  33. }
  34. taskOwners = ownerIds.removeLastOccurence(",");
  35. if(isOwnerPresent)
  36. {
  37. totalHours = totalWorkHours / ownerCount;
  38. updateTaskParameter.put("owner_work",taskWorks);
  39. updateTaskParameter.put("work_type","work_hours");
  40. updateTaskParameter.put("person_responsible",taskOwners);
  41. updateTaskResponse = zoho.projects.update(portalId,projectId,"tasks",taskId,updateTaskParameter,"connectionprojects");
  42. }
  43. }
  44. else
  45. {
  46. // Get Task Details
  47. taskResponse = zoho.projects.getRecordById(portalId,projectId,"Tasks",taskId,"connectionprojects");
  48. owners = taskResponse.get("tasks").get(0).get("details").get("owners");
  49. durationType = taskResponse.get("tasks").get(0).get("duration_type");
  50. duration = taskResponse.get("tasks").get(0).get("duration");
  51. if(durationType.containsIgnoreCase("hrs"))
  52. {
  53. totalHours = duration.toDecimal();
  54. }
  55. else
  56. {
  57. portalInfo = invokeurl
  58. [
  59. url :endPoint + portalId + "/"
  60. type :GET
  61. connection:"connectionprojects"
  62. ];
  63. businessHours = portalInfo.get("portals").get(0).get("settings").get("business_hours");
  64. business_start = businessHours.get("business_start");
  65. business_end = businessHours.get("business_end");
  66. businessTotalHours = (business_end - business_start) / 60;
  67. totalHours = duration.toDecimal() * businessTotalHours;
  68. }
  69. ownerCount = owners.size();
  70. for each  owner in owners
  71. {
  72. if(owner.get("name").containsIgnoreCase("Unassigned"))
  73. {
  74. break;
  75. }
  76. else
  77. {
  78. isOwnerPresent = true;
  79. ownerWorkHours = totalHours / ownerCount;
  80. taskWork = Map();
  81. taskWork.put("user_id",owner.get("id"));
  82. taskWork.put("working_hours",ownerWorkHours.round(2));
  83. taskWorks.add(taskWork);
  84. ownerIds = ownerIds + owner.get("id") + ",";
  85. }
  86. }
  87. taskOwners = ownerIds.removeLastOccurence(",");
  88. if(isOwnerPresent)
  89. {
  90. updateTaskParameter.put("owner_work",taskWorks);
  91. updateTaskParameter.put("work_type","work_hours");
  92. updateTaskParameter.put("person_responsible",taskOwners);
  93. updateTaskResponse = zoho.projects.update(portalId,projectId,"tasks",taskId,updateTaskParameter,"connectionprojects");
  94. }
  95. }
  96. return "success";
Watch this space for more such custom functions
    • Sticky Posts

    • Update on V2 API End-of-Life Timeline

      Dear Users, Earlier this year, we shared the launch of the V3 APIs and requested users to migrate from the older V2 APIs by December 2025. We have received valuable feedback from our users and partners regarding their migration timelines. We are happy
    • Introducing the Zoho Projects Learning Space

      Every product has its learning curve, and sometimes having a guided path makes the learning experience smoother. With that goal, we introduce a dedicated learning space for Zoho Projects, a platform where you can explore lessons, learn at your own pace,
    • Automation Series: Auto-update Phase Status

      Hello Folks! You can auto-update your phase's status based on status of underlying tasks using custom functions. In this series, we will showcase how to create and run custom functions, using Deluge, with ease. Follow the steps below and automate your
    • Automate Timesheet Approvals with Multi-level Approval Rules

      Introducing Approval Rules for Timesheets in Zoho Projects. With this automation, teams can manage how timesheets are reviewed and approved by setting up rules with criteria and assigning approvers to handle submissions. Timesheet, when associated to
    • Accessibility Spotlight Series - 1

      Every user interacts with products differently, what feels intuitive to one may be challenging for another. Addressing this, accessibility is built into Zoho Project's design philosophy. This helps users navigate and perform actions with ease irrespective
      • Recent Topics

      • New feature request: Allow copy of email message to another folder

        Hello Zoho team, This is a suggested new feature to allow copy an email message to either another folder or the same folder. Within the same Zoho account. This is not a support request about "label". This is a suggested new feature to allow copies of
      • Hotmail is blocking the zoho mail IP

        Greetings, Since last Tuesday (5 days ago today) I wrote to Zoho support and I still haven't received a single response (Ticket ID: 2056917). Is this how you treat people who pay for your email service? I am making this public so that those who want to
      • Desk DMARC forwarding failure for some senders

        I am not receiving important emails into Desk, because of DMARC errors. Here's what's happening: 1. email is sent from customer e.g. john@doe.com, to my email address, e.g info@acme.com 2. email is delivered successfully to info@acme.com (a shared inbox
      • Creator Simplified #11: Create a custom button to download files

        Hey there! This time, let's see how to create custom buttons to download the files uploaded in the file upload field. Sample use-case A training app has a module that provides the materials for all the available courses. Students can click on the corresponding
      • Hide horizontal lines at bottom of form

        Hi I have a page with 3 forms embedded in html snippets. On each of the forms I can hide the submit button easily but I am left with the horizontal lines that bound that section and I cannot figure out to remove them (see below for the two sets of horizontal
      • Autosaving of Form Field

        HI can anyone suggest a way of autosaving or simulating an autosave function for a specific field in a form. The story is as follows. I have a bunch of technicians who write notes on how they do a repair. Sometimes they write for a couple of hours the troubleshooting process. If they click incorrectly, press ESC, Cancel or the browser crashes the information is lost which can be heartbreaking so my guys use notepad and then copy the information in. The only way around this is to click submit on the
      • Zoho Tracking Image location

        So we've been having an issue with tracking email opens. Specifically in Gmail. Our emails are not that long either, maybe 4 sections of image/250 characters of text/button per section.  But all my test accounts I used via Gmail we're showing opens. But then come to find out the tracking image is at the very bottom of the email. So If the message is clipped (It always just clips our social icons on the bottom) and the user doesn't click the show more button it never tracks the open.  Looking at other
      • AI Interview Insights: Turn Recorded Interviews into Quick Transcripts & Summaries

        Evaluating interviews shouldn’t require replaying long recordings or taking manual notes. With AI Interview Insights, you can now review complete transcripts and AI-generated summaries of your One-way (Recorded) interviews right inside Zoho Recruit. This
      • API in E-Invoice/GST portal

        Hi, Do I have to change the api in gst/e-invoice portal as I use zoho e books for my e-invoicing. If yes, please confirm the process.
      • Ask the Experts 26: Brighten every customer interaction with Zoho Desk all year long

        Hello everyone, Greetings and welcome to Ask the Experts 26. As we wrap up 2025, we are excited to invite you to the 26th episode of our Ask the Expert series. 🎄The Merry Metrics Edition = Best of Zoho Desk [Best Practices + Holiday Automation + Year-End
      • Pricing calculator

        Alright, so I'm trying to create a pricing calculator/pricing report generator to use in a cabinet shop. I did all the logic and such, and the calculator works. I have a few other things that I would need it to be able to do though, I'll do my best to
      • Bug Details

        In the Bug detail the milestoneid is missing
      • Stop completed task lists from disappearing?

        Is there any way to stop projects from making tasks lists disappear when all the tasks in the list are completed? That's one of those little things where we're constantly fighting the product. For instance we have some projects which are ongoing - no start and end date. We use Kanban view to show the various task lists. We don't want the kanban list to disappear every time the items on it happen to be closed out. Thanks
      • One Contact with Multiple Accounts with Portal enabled

        I have a contact that manages different accounts, so he needs to see the invoices of all the companies he manage in Portal but I found it not possible.. any idea? I tried to set different customers with the same email contact with the portal enabled and
      • Change of Blog Author

        Hi, I am creating the blog post on behalf of my colleague. When I publish the post, it is showing my name as author of the post which is not intended and needs to be changed to my colleague's name. How can I change the name of the author in the blogs?? Thanks, Ramanan
      • Allow customers to choose meeting venue and meeting duration on booking page

        My business primarily involves one-to-one meetings with my clients. Given the hybrid-work world we now find ourselves in, these meetings can take several forms (which I think of as the meeting "venue"): In-person Zoom Phone call I currently handle these
      • Booking outside of scheduled availability

        Is there a way for staff (such as the secretary) to book appointments outside of the scheduled availability? Right now to do this special hours must be set each time. There should be a quicker way. Am I missing something?
      • Operation Questions.

        Hello, I hope you are well. To explain a little, we are a company that sells services and products with a technical team responsible for installation and maintenance. Zoho FSM can be useful for the technical team, namely for the technical coordinator
      • Direct Access and Better Search for Zoho Quartz Recordings

        Hi Zoho Team, We would like to request a few enhancements to improve how Zoho Quartz recordings are accessed and managed after being submitted to Zoho Support. Current Limitation: After submitting a Quartz recording, the related Zoho Support ticket displays
      • Update date & time when a cell is edited

        Hi All, I am desiring to have a cell update with the current date and time when another cell is edited. Any ideas?  Thank you
      • Add "Groups" to "Share With" on Reports & All Entries

        Hi, On Forms we can share Publicly, with Specific Users And/Or Specific Groups or All Users. With Reports and All Entries we lack the "Groups" option, please add this as with many users this saves a lot of work. Thanks Dan
      • Add Pause / Resume Option to Zoho Quartz Recordings

        Hi Zoho Team, We would like to request an enhancement to Zoho Quartz recordings: the ability to pause and resume an ongoing recording. Current Limitation: At the moment, when recording an issue with Zoho Quartz, the recording continues even when we are
      • Custom Fields Not Showing Up in Invoice PDF Template Document Information

        I have added 2 custom fields under Sales > Invoices > Manage Custom Fields. They are set to show in all PDFs. However when I am editing my Invoice PDF template, i do not see the custom fields under Document Information.
      • Tracking Non-Inventory Items

        We have several business locations and currently use zoho inventory to track retail items (sales and purchase orders). We were hoping to use zoho inventory to track our non-inventory items as well (toilet paper, paper towels, etc). I understand that we
      • Can I use a Standalone CRM Function as the Callback URL For Async Export Data API?

        I am creating an export job using this API https://www.zoho.com/analytics/api/v2/bulk-api/export-data-async/create-export/view-id.html There is a "callbackUrl" key in the CONFIG object. I tried copying the URL for a standalone function in CRM which can
      • ZOHO Books

        Hi there, Why after I upgrade my Zoho invoice > Books then i wanted to add plugin which i cannot do. Please advise.
      • How is Your eCommerce Experience w/Zoho Inventory?

        First off, I'm SUPER grateful for the advent of Zoho Inventory and now the Zoho Commerce Suite. Overall, Inventory is a great product, especially for customers without an eCommerce presence. For eCommerce companies (especially those shipping more than ~10 packages/day), however, there are certain drawbacks that keep my clients from moving over to Zoho Inventory: Cons: 1. Invoice + Package Creation from Shopify/Other eCommerce Integrations: Zoho Inventory makes the somewhat perplexing decision to
      • Error AS101 when adding new email alias

        Hi, I am trying to add apple@(mydomain).com The error AS101 is shown while I try to add the alias.
      • Simplify Mass Replies with Predefined Templates and Snippets

        Hello everyone, We are happy to introduce a new enhancement to Mass Reply that helps agents respond to customers quickly and consistently. With the addition of Email Templates and Snippets in the reply window, agents can use predefined messages while
      • Mapping custom fields from one module to another

        I have a custom field, "Subscription Period" that appears as a required field in every Opportunity (Potential). I want that field to appear on any Quotes derived from that Opportunity (and have created a custom field of the same name in Quotes for that
      • The Social Wall: November 2025

        We’re nearing the end of the year, and the holiday season is officially kicking in! It’s that time when sales peak and your social media game needs to be stronger than ever. We’re back with exciting new updates across AI, analytics, and the mobile app
      • Item name special charaters <>

        Im trying to input speical characters such as < and > into item name and item description but comes up with following error: Invalid value passed for Item Name and Invalid value passed for Item Description How do i allow speical characters?
      • How to update Multi File upload field

        Assume that i have a multi file upload field,how can i update the same field again?
      • Customer Address Not on Standard Invoice when Address is on Contact Record

        Hi,  I entered the customer billing and shipping address in Zoho CRM. I created an invoice in Zoho Books with the same customer contact. The contact is correctly in Zoho Books with the billing and shipping address. The invoice for the customer does not
      • Apply partial payments to invoices from the Banking Module

        We need this! Why is this not possible?
      • Welcome to the Zoho Show Community Forums page!

        Hello everyone, The Zoho Show community is a place for you to discuss and share anything and everything related to Zoho Show Presentations, our online presentation software. It includes users from all over the globe and all walks of life. Our community helps answer your Zoho Show questions with responses from other knowledgeable community members to give you the best experience creating and designing exciting presentations. Along the way, you'll meet recognized experts from our software team and
      • How can I convert an existing contact into a lead?

        I imported many contacts into ZOHO CRM. In order to select a few of them as leads, I want to mark or convert a few hundred as Leads. Who can I do that?
      • Introducing Dedicated Modules for Plans, Addons, and Coupons in Zoho Billing

        We’ve enhanced the way you manage Plans, Addons, and Coupons in Zoho Billing. Previously, all three grouped together under Subscription Items. Now, each one has its own dedicated module, giving you a cleaner and more intuitive experience. This update
      • Price book functionality enhancement

        A common use of price books is to create a price book for a given customer level or contract with a specific company. Given that this is done at a company/customer level it would be great to see a way to associate a price book to a given customer and
      • Tracking Emails sent through Outlook

        All of our sales team have their Outlook 365 accounts setup with IMAP integration. We're trying to track their email activity that occurs outside the CRM. I can see the email exchanges between the sales people and the clients in the contact module. But
      • Next Page