Power of Automation :: Automatically update the Work hours of a task based on Custom field Value

Power of Automation :: Automatically update the Work hours of a task based on Custom field Value

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. 


Lets take the below use case from a customer - 


They have created a custom field 'Task Type' at task level. Based on the value provided to that field, work hours should be automatically updated in that task. Below are the mappings between Task Type & Work Hours.


Task Type

Work Hours

AAIR

12 hours

Account Intel

32 hours

Competitor Intel

8 hours

Connects

8 hours

Custom Intel

9 hours

Deal Shortlisting

2 hours

IT Intel

4 hours

Priority Task

10 hours

Profiling

8 hours

Quarterly Analysis

16 hours

Win Loss

8 hours


This can be accomplished using the below code. Create a connection using the scopes “ZohoProjects.portals.READ, ZohoProjects.tasks.ALL, ZohoProjects.timesheets.READ” and update the connection name ‘******’ in the below code. Find the attached screenshot of the Arguments.

Here is the link to know how to create a connection.

// scopes: ZohoProjects.portals.READ, ZohoProjects.tasks.ALL, ZohoProjects.timesheets.READ

workhourMapping = Map();
workhourMapping.put("AAIR", 12);
workhourMapping.put("Account Intel", 32);
workhourMapping.put("Competitor Intel", 8);
workhourMapping.put("Connects", 8);
// workhourMapping.put("Custom Intel", Yet to decide);
workhourMapping.put("Deal Shortlisting", 2);
workhourMapping.put("IT Intel", 4);
// workhourMapping.put("Priority Task", Yet to decide);
workhourMapping.put("Profiling", 8);
workhourMapping.put("Quarterly Analysis", 16);
workhourMapping.put("Win Loss", 8);
if(taskType==null || !workhourMapping.containKey(taskType)) {
return "Task type is empty or map doesn't contain the specified task type";
}
else {
taskResponse = zoho.projects.getRecordById(portalId,projectId,"Tasks",taskId,"projects");
owners = taskResponse.get("tasks").get(0).get("details").get("owners");
// info owners;
taskWorks = List();
for each  owner in owners
{
if(owner.get("name").containsIgnoreCase("Unassigned"))
{
info "No owner found";
break;
}
else
{
isOwnerPresent = true;
ownerId = owner.get("id");
ownerWorkHours = workhourMapping.get(taskType);
taskWork = Map();
taskWork.put("user_id",ownerId);
taskWork.put("working_hours",ownerWorkHours);
taskWorks.add(taskWork);
break;
}
}
// info taskOwners;
updateTaskParameter = Map();
if(isOwnerPresent)
{
updateTaskParameter.put("owner_work",taskWorks);
updateTaskParameter.put("work_type","work_hours");
updateTaskParameter.put("person_responsible",ownerId);
updateTaskResponse = zoho.projects.update(portalId,projectId,"tasks",taskId,updateTaskParameter,"********");
info updateTaskResponse;
}
}
return "success";


Creating custom functions in Zoho Projects is straightforward and well-documented. Zoho provides a range of built-in functions that you can use as a starting point, and you can also easily define your own functions using Zoho's scripting language, Deluge. Give it a try and see how it can save your time and boost your productivity!

 

Watch this space for more such custom function codes. 



      • Sticky Posts

      • Schedule Exports for Regular Project Updates

        Tracking project data often means exporting data at regular intervals. Instead of manually exporting data every time, users can schedule exports for Phases, Tasks, and Tasks in Zoho Projects. These exports can be set to run once, daily, weekly, or monthly
      • 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:

        • Recent Topics

        • One time sale item in billing automatically detects as service

          if i have some items which i don't want to add in my "item" list because its sold only for one time. but when i type item name in invoice, it (system) automatically takes it as a service and despite of HSN , it shows SAC code to be entered. if its selectable i.e. either item or service , it would be very helpful and a must have feature.
        • Project template after project creation

          How can I apply a project template AFTER the project has been created?
        • convert the project to templet

          i have some deployment ME product for different customer , i need to create a fixed template for use it rather then keeping creating this template every time
        • 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?
        • Seriously - Create multiple contacts for leads, (With Company as lead) Zoho CRM

          In Zoho CRM, considering a comapny as a lead, you need us to allow addition of more than one contact. Currently the Lead Section is missing "Add contact" feature which is available in "Accounts". When you know that a particular lead can have multiple
        • Related Module in Sharing Rules

          Zoho CRM team recently added the feature to filter records by Related Records It will be really beneficial if we can have this feature for Sharing Rules as well
        • Assignment Thresholds Resetting After Lead Conversion

          Hello everyone, We're facing an issue with Zoho CRM's lead assignment thresholds that makes them unsuitable for our workflow. I'm hoping to find a potential workaround or solution from the community. Here’s our current process: A new lead is created automatically
        • Zoho CRM Analytics - Allow To Reorder Dashboards

          I would like to suggest that you add the ability to reorder dashboards in the Analytics Module. I can see that this has been requested some time ago, the latest 9 years ago. I am not sure if this is a big or small endeavor, but such a small fix can go
        • Territory view for custom modules?

          I have recently activated territories however I can't seem to find how to use territories for custom modules? These modules have territories:  Contacts /  Accounts / Opportunities These modules don't have territories:   Buildings (custom module) and 
        • Zoho Books - How to Invoke a Custom Function in Schedulers

          We have multiple schedulers that send emails to customers in batches. Currently, we are maintaining the same code across several schedulers. Is it possible to use a custom function inside a scheduler script? If yes, how can we invoke the custom function
        • Approval Process Comments

          Is it possible to view the comments entered during the approval or rejection of a record in the approval process? If not, is there a way to require a field to be completed upon approval or rejection?
        • Login for test case

          Had a few questions regarding authentication test cases and couldn't find an answer in the the docs. 1. If an app like Zoho Creator requires authentication before providing access, do I need to create a login function and add it to each test case? 2.
        • Zoho / Outlook Calendar sync

          The current Marketplace -> Microsoft -> Meetings integration needs 2 changes. 1. The current language for the Two-Way sync option should be changed. It currently states, "Sync both your Zoho CRM Calendar and Office 365 Calendar meetings with each other."
        • Please make it easier to Pause syncing

          right now it takes 3 clicks to get there. sounds silly, but can you make it just 2 clicks to get it done instead? thats how dropbox does it, 2 clicks to pause instead of 3.
        • Customer members area

          Does FSM support a customer members area? If not what do you propose we use if we want the data used in FSM for customers to give them an area / login to see past orders, create new orders and general announcements.
        • Zoho Books-Accounting on the Go Series!

          Dear users, Continuing in the spirit of our 'Function Fridays' series, where we've been sharing custom function scripts to automate your back office operations, we're thrilled to introduce our latest initiative – the 'Zoho Books-Accounting on the Go Series'.
        • Desktop app doesn't support notecards created on Android

          Hi, Does anybody have same problem? Some of last notecards created on Android app (v. 6.6) doesn't show in desktop app (v. 3.5.5). I see these note cards but whith they appear with exclamation mark in yellow triangle (see screenshot) and when I try to
        • Notes created in mobile can no longer be accessed in desktop

          Working with a 2013 Mac running OS 10.14.6; Desktop Notebook version 4.5.3. Using Motorola Moto G Power 5G - 2024; Android app version 6.7 I have been using Notebook for some years. Starting several weeks ago, the notes newly created ion the phone can
        • Function #49: Manage varying installment payments using Zoho Books

          . Hello everyone, and welcome back to our series! Last week, we discussed automating the collection of fixed installment payments in Zoho Books. But what if your payment structure involves charging varying percentages of the invoice total as installments?
        • Open Sans Font in Zoho Books is not Open Sans.

          Font choice in customising PDF Templates is very limited, we cannot upload custom fonts, and to make things worse, the font names are not accurate. I selected Open Sans, and thought the system was bugging, but no, Open Sans is not Open Sans. The real
        • Zoho Writer - Option to Export as .zdoc format

          I've noticed that it's not possible to export a Zoho Writer Document in the .zdoc format. Isn't zdoc, Zoho Writer's own format? My use case is that I sometimes need to create quite complex documents with floating elements, which sometimes need to become
        • Is it possible for contacts to "Re-enter" a workflow in Zoho Campaign?

          We are currently working on a way to automatically add users to from one list to other lists based on specific criteria, but can't seem to find a native way of doing this so we are trying to use Workflows to do this. So, for example, if a user's status is set to "Active," then they should be added to the list "Active Users." If the same user's status is then set to "Paused," they should be added to the list "Paused Users" and removed from the list "Active Users." This works fine for the first go
        • Bulk upload images and specifications to products

          Hi, Many users have asked this over the years and I am also asking the same. Is there any way in which we can bulk upload product (variant) images and product specifications. The current way to upload/select image for every variant is too cumbersome.
        • Out of Office for Just One of My Alias Email

          Can I set up the Out of Office Reply for Just One of my Alias Email Addresses?
        • Can I map multiple Surveys into the CRM using the same fields?

          Hello, We are a healthcare practice that offers two distinct services (Nutrition and Primary Care). We use Zoho Survey for our lead generation form (Get Started Survey), which allows people to express interest in one of the two services and even allows
        • Dealing with API responses where integers have more than 16 digits

          Hi there How do I deal with an api response contaning an int or float with more than 16 digits (before any decimal places for a float). I constantly receive the response "Unable to cast the 'BigInteger' value into a 'BIGINT' value because the input is
        • To Zoho customers and partners: how do you use Linked Workspaces?

          Hello, I'm exploring how we can set up and use Linked Workspaces and would like to hear from customers and partners about your use cases and experience with them. I have a Zoho ticket open, because my workspace creation fails. In the meantime, how is
        • Can't change form's original name in URL

          Hi all, I have been duplicating + editing forms for jobs regarding the same department to maintain formatting + styling. The issue I've not run into is because I've duplicated it from an existing form, the URL doesn't seem to want to update with the new
        • Need Inactive accounts to be visible in Reports in Zoho Books

          I N=need Inactive accounts to be visible in Reports in Zoho Books to do recons of the accounts but when i see the same they are not visible in the Accountant - Account Transactions report
        • unblock e-mail

          please unblock my e-mails info@meatnews.gr and myrtokaterini@meatnews.gr
        • Add Zoho Mail for users who do not need Zoho One

          We have licenses for ZOho One for teams that need to use the suite of products that Zoho One offers.  We have 8 more people who only need email access and we would like to add just a Zoho Mail.  They do not need the Zoho One license.  We are currently
        • Zoho Projects - Q2 Updates | 2025

          Hello Users, With this year's second quarter behind us, Zoho Projects is marching towards expanding its usability with a user-centered, more collaborative, customizable, and automated attribute. But before we chart out plans for what’s next, it’s worth
        • ZML vs HTML Snippet - which is better?

          Are there certain use cases where one is better than the other?
        • Auto CheckOut Based On Shift.

          This Deluge script runs on a scheduled basis to automatically set the 'Actual_Check_Out' time for employees who haven't manually checked out. If the current time is past their scheduled 'Shift_End_Time', the script updates the check-out time to match
        • How to remove some users in zoho accounts

          How to remove some users in Zoho accounts.
        • Customizing Form Questions per Recipient Group in Zoho Campaigns/Forms

          Hello everyone, I would like to ask if it’s possible in Zoho Campaigns or Zoho Forms to send out a campaign where the form questions can be customized based on the group of recipients. Use case example: I have prepared 20 questionnaire questions. For
        • Infinite loop of account verification

          Hi I can't do anything on my zoho account.  I always get this message Hi Sheriffo Ceesay As a security measure, you need to link your phone number with this account and verify it to proceed further. When ever I supply the details, it displays that the number is associated with another account. I don't have any other account on zoho so this is really annoying. 
        • Load PO_Date field (Purchase Order) with current date in Deluge

          Hi, I'm not a full time developer, just helping to customize our CRM, in the small company I work for. There must be something wrong with me, because I can't do something so simple as complete a field with the current date in a function using Deluge.
        • Zoho CRM in Microsoft Power Automate Custom Connector

          Hi everyone, I’m building a Power Automate flow that integrates Microsoft Bookings with Zoho CRM. The goal is to automatically create a meeting (event) in Zoho CRM whenever a new appointment is booked via Microsoft Bookings. To achieve this, I created
        • [Webinar] Automate sales and presales workflows with Writer

          Sales involves sharing a wide range of documents with customers across the presales, sales, and post-sales stages: NDAs, quotes, invoices, sales orders, and delivery paperwork. Generating and managing these documents manually slows down the overall sales
        • Next Page