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.

      • Sticky Posts

      • 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,
      • Time Based Workflow Rules for Projects and Tasks

        Project managers spend a significant amount of time manually monitoring task deadlines, notifications, and follow ups. Zoho projects' Workflow Rules help automate these repetitive processes and save valuable time. Workflow rules are a set of actions that
      • 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:
      • Zoho Projects Roadshow, USA - 2024

        Dear Users, We are happy to announce the Zoho Projects Roadshows 2024 in USA. This is an excellent opportunity to learn more about Zoho Projects and gain in-depth knowledge of the advanced features. Our team will also discuss industry specific solutions
      • Project Billing with the Staff Hours Method in Zoho Projects

        The Staff Hours Billing Method in Zoho Projects allows you to bill your clients based on the actual time spent by each team member on a project, at the rate set for each user. This is useful for projects where different skill sets are needed and service

        • Recent Topics

        • Update Client Record based on creation of custom module record

          Hi! Hoping for someone's help with this one. I have a custom module called 'Agreement History. Whenever a deal is won, it creates a new record in this module with associated 'Products' and 'Clients' to track rental history and contracts. What I'm trying
        • Zoho Workdrive Fixed View or Sort Settings for External Links

          Hi , For the folder links we shared via an external link, it would be great if we could set the view and sort options that the external user will see when accessing the file through the link. Thanks to everyone.
        • Zoho Creator Upcoming Updates - March 2025

          Hello everyone, We hope you’ve had the chance to explore Release Projection 1 for 2025! This month, we’re keeping up the momentum by bringing even more powerful features and enhancements to Zoho Creator. Here's what you can expect in March: App menu builder
        • Workflows for Timesheet

          Good day, Any way to have timesheet as triggers? I looked into Zoho Flow and into Zoho Project automation but no where can I have timesheet as a trigger. Basically, I would like to trigger something upon timesheet approval. Right now, the only way to
        • Duplicate Contact Records in Zoho CRM

          Hi team, Has anyone experienced an issue in Zoho CRM where contact records are suddenly being duplicated? I noticed today that some of our existing records appear to have been added again as new contacts earlier this morning. Appreciate any insights or
        • Not receiving New Ticket Emails

          Hello! The company I work for uses the Zoho ticketing system, however, I've noticed I'm not receiving email notifications when new tickets are published. I have admin rights to see these tickets on Zoho Desk and respond to them, but am not receiving the
        • Using Zoho One to manage two (or more) businesses

          We are one company that operates two business, a scenario that Zoho One doesn't really seem to handle very well, and one which I can't imagine is at all unique to us! (It is basically designed to facilitate branding and use for one business only per subscription).
        • VOORRAADTELLING - Kom er met me verstand niet helemaal bij.....

          Beste Zoho One, Wij hebben mega veel producten van zoho maar dit begrijp ik werkelijk niet. Wij gebruiken voornamerlijk ZOHO FSM met ZOHO INVENTORY omdat wij in service en onderhoud zitten voor elketrische laadstations voor auto's Alle medewerkers van
        • Success message - Warning message

          We already have the "success message". The alert does not work in the report action; a "warning message" (with red color) would be ideal. Additionally, we should be able to set the duration which the message stays before it fades out, as it is currently
        • MA 2.0 Email Footer

          Good day, I recently went through the nightmare of upgrading from MA 1.0 to MA 2.0 and continue to experience more problems or missing features and settings. In this particular case, I am trying to find where and how to edit the Email Footer in MA 2.0.
        • books+POS+ tap to pay+ stripe

          So in the UK we now have tap to pay with stripe. So we can use the stripe app as a POS terminal. Brilliant news. Can we hope that the Books App might add this feature ASAP. It would be great to have one system rather than using the not very good Square
        • Instantly refine your CRM dashboard using Filters and download underlying data – all in a few clicks!

          Hello everyone, Imagine you’re a sales manager overseeing multiple product lines across different regions. You're viewing your sales dashboard in Zoho CRM, which gives a powerful overview, but you often need to drill down to see how a specific product
        • Custom Related List anchor tag with tel protocol

          The following code worked great for about a year to create clickable tel and mailto links in a related list in the Deals module. Just this morning, it started displaying the HTML as text. For example: <a href='tel:8882490100'>8882490100</a> Zoho support
        • How to create a contract using Zoho Contracts API and have the systemStatus directly assigned as "Active"?

          Hi Team, How do I create a contract using Zoho Contracts API and have the systemStatus directly assigned as "Active" instead of "Draft"? Currently, I'm able to create a contract but the systemStatus is "draft". Kindly help.
        • Python - code studio

          Hi, I see the code studio is "coming soon". We have some files that will require some more complex transformation, is this feature far off? It appears to have been released in Zoho Analytics already
        • Syncing with Google calendar, Tasks and Events

          Is it possible to sync Zoho CRM calendar, task and events with Google Calendar's tasks and events. With the increasing adoption by many major tool suppliers to sync seamlessly with Google's offerings (for instance I use the excellent Any.do task planning
        • Filtert products by multi select custom field

          Hello, this is seems like a must addition, why it can not be done now?
        • CRM quotes and sub forms.

          Recently upgraded to Enterprise CRM - now some added hopes/questions * In a subform in quotes, if I add a "Percent" field, called Overage for instance. I would expect it to allow me to enter a percent like "10%" and carry the percent forward to formulas
        • Is there a notification API when a new note is addeding

          Trying to push to Cliq, or email notification when there's a new note added in module. How to implement this?
        • Problem with WorkDrive and Vivo X200 Pro

          Hey there, after a long odyssey of searching for a new phone, several issues and defects with a phone from another brand and many reinstallations and transfers I stuck to the Vivo X200 Pro. So far, so great. Only thing not working is the Zoho WorkDrive,
        • Cambiar nombre de usuario

          Hola. Tengo una cuenta en zoho, por ejemplo Minombre @ midominio.es Y quiero cambiarlo a Miotronombre @ midominio.es Se puede cambiar??? Con la cuenta gratuita de zoho, cuantos nombres puedo tener en un dominio??? Gracias y buen dia
        • Can't add company logo and favicon as a superadmin

          I am logged in as the superadmin but can't add company logo and favicon - the fields are greyed out. Any idea as to what the problem could be?
        • Inquiry regarding B2B website through Zoho Commerce

          We are looking to build an online B2B customer portal for Consumer Goods primarily for order placement, with an e-commerce-style layout. Additionally, we would like to offer our customers features such as: 1.Viewing past orders and order updates 2.Accessing
        • ASAP Chrome Extension not loading

          We have ASAP enabled in Zoho Desk. I installed the ASAP Chrome Extension (Windows 10), but when I click the extension button while on our site, it never fully loads. I just get what's shown below.
        • Why is the Zoho portal not mobile friendly?

          I just got started with the portal and im sort of shocked how it looks. I already filled a hint/complaint about this. On the website you see a wonderful site with a modern design. Yet in real life its a mid 2000 look and feel. One major issue i see thats
        • New Asap Widget How to update my code

          I know you're still working on updating the documentation for calling the Asap Widget, the existing documentation is no longer valid. In the old 1.0 version I was able to do many things programmatically in javascript. I could open an article directly
        • Condition in templates

          Is it possible for me to add merge field conditionally in my templates. For example Dear ${Leads.Gender == "Male" ? "Sir" : "Ma"},
        • How to Dynamicaly display image in the Detailed View Report ?

          I have an "Add Employee" form that includes an image field for uploading an employee's profile picture from their local computer. In the "Apply Leave" form, I also have an image field where I want the employee's profile picture to be auto-populated based
        • Zoho Flow Custom Function to Register Sale in Zoho Thrive

          Hi Thrive team, I want to create a custom function which sends purchase information back into Thrive for Affiliate commission. I'm stuck on how to setup the connection, specifically creating an OAuth connection through https://api-console.zoho.eu/ Please
        • Sending User-centric reports to all users

          I would like to automate an e-mail report to all users that sends them a weekly e-mail listing their open Potentials.  I've created a Report that uses the ${CURRENTUSER} criterion and scheduled the report to send to several users, but they all receive
        • How do I add new line and format text in zoho desk ticket?

          I am generating a ticket via API and looking to update "description" field of ticket whenever I need. Is there a document where I can find supported formatting for description field on a ticket.  I need to find: Adding a new line and adding bold text,
        • Automation #6 - Prevent Re-opening of Closed Tickets

          This is a monthly series where we pick some common use cases that have been either discussed or most asked about in our community and explain how they can be achieved using one of the automation capabilities in Zoho Desk. Typically when a customer submits
        • Feature Request - Insert URL Links in Folders

          I would love to see the ability to create simple URL links with titles in WorkDrive. or perhaps a WorkDrive extension to allow it. Example use case: A team is working on a project and there is project folder in WordDrive. The team uses LucidChart to create a drawing/s for the project. The team member could create a link to the LucidChart drawing/s and allow WordDrive to truly be a repository for ALL the project documents, even those outside of WorkDrive. A folder is dedicated to a CRM account. A
        • ZOHO DESK ヘルプセンターの言語選択メニューの表示方法

          ZOHO DESK のヘルプセンターを構築し、多言語化設定をしました。 顧客のヘルプセンター画面右上に言語選択メニューが表示されないため、弊社の契約先会社に問い合わせましたが、「通常は多言語化をオンにすると表示するためCSS を触り過ぎではないか」 という指摘のみでした。 試行中ですが表示できません。 何か要因となる情報をお持ちの方がいましたらご教授いただけますと幸いです。 ↓の赤枠を表示したいのですが、表示できません。
        • How to reply to thread via API

          We have built a webapp for our customers that uses the Zoho Desk API to enable each customer to view their full list of tickets, view individual tickets and raise new tickets. The Zoho Desk API doesn't have the ability to reply to a ticket/thread. Replies
        • Email Builder Editor is not functioning or loading correctly

          Email editor function is not working or loading correctly in any template, new or old. Cleared my cache, restarted browser, problem unchanged.
        • Create Tasklist with Tasklist Template using API v3

          In the old API, we could mention the parameter 'task_template_id' when creating a tasklist via API to apply a tasklist template: https://www.zoho.com/projects/help/rest-api/tasklists-api.html#create-tasklist In API v3 there does not seem to be a way to
        • Issue in downloading the sent logs

          Hi Team, I'm unable to export the sent file for any email campaign. When selecting all fields, the system indicates that the document will be sent via email, but I haven't received it. At times, it shows a download option, but the file doesn’t get downloaded.
        • Integrate Google Chat with Zoho CRM for seamless collaboration

          Hello everyone, Sales is a team sport and sales reps have to be in constant communication with people inside and outside their organization. While email remains the most effective channel for important conversations, sales reps often collaborate via chat.
        • customers enter orders?

          Anyway we can let a customer into CRM and enter their own orders , no access to anything else except history reports, no access to any other contacts. Greg Aanes 2109 Queen Street Bellingha WA USA
        • Next Page