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. 



      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

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

          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

                                  • Granular Email Forwarding Controls in Zoho Mail (Admin Console and Zoho One)

                                    Hello Zoho Mail Team, How are you? At present, the Zoho Mail Admin Console allows administrators to configure email forwarding for an entire mailbox, forwarding all incoming emails to another address. This is helpful for delegation or backup purposes,
                                  • Apply Advance option not shown in report

                                    We are facing an issue in Zoho Expenses. While approving an Expense Report, the "Apply Advance" option is not appearing under the three dots (More Options). Details: Module: Expense Reports Issue: "Apply Advance" option not visible Status of Report: Awaiting
                                  • Introducing Assemblies and Kits in Zoho Inventory

                                    Hello customers, We’re excited to share a major revamp to Zoho Inventory that brings both clarity and flexibility to your inventory management experience! Presenting Assemblies and Kits We’re thrilled to introduce Assemblies and Kits, which replaces the
                                  • 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
                                  • Follow-up emails via Workflow Automation not staying in the same thread

                                    Dear Zoho Support Team, I am currently using Workflow Automation in Zoho Campaigns to send follow-up emails. In my test case, I noticed the following behavior: All emails in the automation have the same subject line. If the follow-up email is sent within
                                  • Client Script refuses to set an initial value in Subform field

                                    I tried a very simple, 1 line client script to set a default value in a custom subform field when the "Add Row" button is clicked and the user is entering data. It does not work - can someone tell me why? ZDK documentation suggests this should be doable.
                                  • Formatting of Balance Sheet and Profit & Loss Reports

                                    The default format of the Balance Sheet and P&L Reports are based on the Account Types and then the individual accounts within the Chart of Accounts. These are then ordered alphabetically under these sub-headings and one is unable to re-order these or
                                  • Pourquoi dans zohobooks version gratuite on ne peut ajouter notre stock d'ouverture??

                                    Pourquoi dans zohobooks version gratuite on ne peut ajouter notre stock d'ouverture ??
                                  • Week date range in pivot table

                                    Hello, I need to create a report that breakouts the data by week.  I am using the pivot table report, and breaking out the date by week, however the date is displayed as 'Week 1 2014' format.  Is there anyway to get the actual dates in there? ex. 1/6/2014-1/12/2014 Thanks,
                                  • 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
                                  • Staff rules

                                    Hi! Do you people know what are the default staff rules when a new booking is created? We have two staff members in my team (me as the admin, and my employee). As we share the same services, I'm wondering how Zoho will pick the staff for new apointments.
                                  • Comment Templates

                                    Is it possible to add a template option for comments? We have some agents in the process who's responses require a pre-formatted layout. It would be incredibly handy to have a template for them where they can insert the template and then add their responses
                                  • [ZohoDesk] Improve Status View with a new editeble kanban view

                                    A kanban view with more information about the ticket and the contact who created the ticket would be valueble. I would like to edit the fields with the ones i like to see at one glance. Like in CRM where you can edit the canvas view, i would like to edit
                                  • 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
                                  • An Exclusive Session for Zoho Desk Users: AI in Zoho Desk

                                    A Zoho Community Learning Initiative Hello everyone! This is an announcement for Zoho Desk users and anyone exploring Zoho Desk. With every nook and corner buzzing, "AI's here, AI's there," it's the right time for us to take a closer look at how the AI
                                  • Shared values: From classroom lessons to teaching moments in customer service

                                    While the world observes Teachers’ Day on October 5, in India, we celebrate a month earlier, on September 5, to mark the birth anniversary of Dr. Sarvepalli Radhakrishnan, a great teacher, renowned scholar, educationist, and advocate for empowerment.
                                  • Export to excel stored amounts as text instead of numbers or accounting

                                    Good Afternoon, We have a quarterly billing report that we generate from our Requests. It exports to excel. However if we need to add a formula (something as simple as a sum of the column), it doesn't read the dollar amounts because the export stores
                                  • Create a list of customers who participated in specific Zoho Backstage events and send them an email via Zoho CRM

                                    How to create a list of customers who participated in specific Zoho Backstage events and send them an email via Zoho CRM? I was able to do a view in CRM based on customer that registered to an event, but I don't seems to be able to include the filter
                                  • Zoho Desk blank page

                                    1. Click Access zoho desk on https://www.zoho.com/desk/ 2. It redirects to https://desk.zoho.com/agent?action=CreatePortal and the page is blank. Edge browser Version 131.0.2903.112 (Official build) (arm64) on MacOS
                                  • I hate the new user UI with the bar on the left

                                    How can I reverse this?
                                  • Constant color of a legend value

                                    It would be nice if we can set a constant color/pattern to a value when creating a chart. We would often use the same value in different graph options and I always have to copy the color that we've set to a certain value from a previous graph to make
                                  • Question regarding import of previous deals...

                                    Good afternoon, I'm working on importing some older deal records from an external sheet into the CRM; however, when I manually click "Add New Deal" and enter the pertinent information, the deal isn't appearing when I look at the "Deals" bar on the account's
                                  • Client Script also planned for Zoho Desk?

                                    Hello there, I modified something in Zoho CRM the other day and was amazed at the possibilities offered by the "Client Script" feature in conjunction with the ZDK. You can lock any fields on the screen, edit them, you can react to various events (field
                                  • One person/cell phone to manage multiple accounts

                                    Hi. I have a personal Free account to keep my own domain/emails. Now I need to create a Business account to my company's own domain, but I have only one mobile phone number I use to everything. How do I do to manage this? Can I manage a Free domain and
                                  • Tracking KPIs, Goals etc in People

                                    How are Zoho People users tracking employee targets in People? For example, my marketing assistant has a target of "Collect 10 new customer testimonials every month". I want to record attainment for this target on a monthly basis, then add it to their
                                  • Zoho Desk: Ticket Owner Agents vs Teams

                                    Hi Zoho, We would like to explore the possibility of hiding the ‘Agents’ section within the Ticket Owner dropdown, so that we can fully utilise the ‘Teams’ dropdown when assigning tickets. This request comes from the fact that only certain agents and
                                  • Can not Use Attachment Button on Android Widget

                                    this always pops up when I touch the attach button on android widget. going to settings, there is no storage permission to be enabled. if I open the app, and access the attach feature there, I can access my storage and upload normally.
                                  • Zoho Notebook Sync problem

                                    I'm facing a problem with syncing of notebook on android app. It's not syncing. Sometimes it syncs after a day or two.  I created some notes on web notebook but it's not syncing on mobile app. Please help!!!!
                                  • Custom Fonts in Zoho CRM Template Builder

                                    Hi, I am currently creating a new template for our quotes using the Zoho CRM template builder. However, I noticed that there is no option to add custom fonts to the template builder. It would greatly enhance the flexibility and branding capabilities if
                                  • Announcing new features in Trident for Mac (1.24.0)

                                    Hello everyone! Trident for macOS (v.1.24.0) is here with interesting features and thoughtful enhancements to redefine the way you plan and manage your calendar events. Here's a quick look at what's new. Create calendar events from emails. In addition
                                  • Need Easy Way to Update Item Prices in Bulk

                                    Hello Everyone, In Zoho Books, updating selling prices is taking too much time. Right now we have to either edit items one by one or do Excel export/import. It will be very useful if Zoho gives a simple option to: Select multiple items and update prices
                                  • Vendor Master Enhancements for Faster Purchase Entry

                                    I’d like to suggest a few features that will improve accuracy and speed during purchase voucher entry: Automated Item Tax Preference in Vendor Master Add an option to define item tax preference in the vendor master. Once set, this preference should automatically
                                  • Mass Mail Statistics - Number of unsent emails

                                    How do I find out which emails were not sent?
                                  • Button to add product to cart

                                    Is there a way to have a button on a page, that when clicked, will add Qty 1 of a product to the cart?
                                  • Est-il possible d'annuler l'envoi d'un mail automatique ?

                                    Bonjour, Lorsque je refuse un candidat, il reçois un mail dans les 24h pour l'informer que sa candidature n'est pas retenue. J'ai rejeté un candidat par erreur. Savez-vous s'il possible d'annuler l'envoi de ce mail ? Merci d'avance pour votre aide.
                                  • 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
                                  • New in Cadences: Option to Resume or Restart follow-ups when re-enrolling records into a Cadence, and specify custom un-enrollment criteria

                                    Managing follow-ups effectively involves understanding the appropriate timing for reaching out, as well as knowing when to take a break and resume later, or deciding if it's necessary to start the follow-up process anew. With two significant enhancements
                                  • embed a form in an email

                                    Hello, how to embed a form in an email that populates Zoho CRM cases? I would like to send emails to a selected audience offering something. In the same email the recipients - if interested - instead of replying to can fill in a Zoho CRM form that creates
                                  • Zoho Bookings - Reserve with Google

                                    Does Zoho Bookings plan to to integrate with Reserve with Google?
                                  • How to add Zoho demo site page designs to my Zoho Sites website

                                    Hi, I would like to add the design from the following demo URLs into my current Zoho website. I have already created two new pages on my site, named “Menu2” and “Menu3.” For the “Menu2” page, I want to use the design from this demo: https://naturestjuice-demo.zohosites.com/menu
                                  • Next Page