Kaizen #154 - Dynamically Update Picklist Values in Zoho CRM Workflows

Kaizen #154 - Dynamically Update Picklist Values in Zoho CRM Workflows



Hello all!
Welcome back to another interesting Kaizen post.
Today, we will discuss how to add automatically or remove values from a picklist field using Deluge within a workflow. This post serves as a solution for the forum post.

Use case

The sales team migrates users from Pipedrive to Zoho CRM. In Pipedrive, the team managed deals using a Kanban view displayed based on the Closing Months (a picklist field). They automated the updating of picklist values to include current and upcoming months based on the deals' closing timelines. 

In Zoho CRM, to replicate this process, users should manually update the picklist values. The requirement is to automate updating the picklist options during record creation or editing within a workflow.

Solution

By triggering the PATCH Fields API (introduced in V6) through a Deluge function within a workflow, this process can be easily automated. Automating picklist updates saves time, reduces the chances of human error, and ensures that picklist values are always up-to-date.
  • First, create a custom picklist field called "Closing Month" in the Deals module.
  • Then, use the custom picklist along with the Closing Date (a mandatory field date field in the Deals module) within a Deluge function in the Workflow. 
  • The PATCH Fields API can be used within the Deluge function to automate updating picklist values and to list the current and upcoming closing dates in deals.
Let us see the steps in detail on how to achieve this case.

Example

Consider the Closing Month as a custom picklist in the Deals module with three months: January, February, and March. Whenever a new deal is created and its closing month matches one of the picklist values, the record will be updated with the corresponding month in the Closing Month field and placed under the existing picklist value in the Kanban view. If the new closing month is not already in the picklist values, then the Deluge function will automatically create a new picklist value, and the record will fall under the new picklist value section in the Kanban view. 

Follow the steps below to achieve our case in Zoho CRM:
  1. Create a Custom Picklist Field in the Deals module.
  2. Set Up a Workflow.
  3. Add a Deluge Function within a workflow.
  4. Configure the Workflow.

1. Create a Custom Picklist Field in the Deals Module

  • Go to Setup > Customization > Modules and Fields.
  • Select the Deals module and the desired layout where you want to add the picklist.
  • Click on New Fields and then Add New Field.
  • Select Picklist as the field type, name it "Closing Month", and add a list of months (In this post, only three months have been added for example purposes).

                                  
  • Click Done to save the new picklist field.

2. Set Up a Workflow

  • Navigate to Setup > Automation > Workflow Rules.
  • Click on Create Rule, select the Deals module, and name the workflow in the Rule Name.
  • Set the rule to trigger on record creation or update.
                               
The workflow triggers based on the value of the Closing Date in the Deals module, executing the function when the Closing Date is not empty.


3. Add a Deluge Function within a workflow

You can either create a custom function or you can associate an existing one. Below is the Deluge code used within the workflow. 
  1. //To map months with Numbers
  2. month = {1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"June",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"};
  3. //To retrieve the Deal record
  4. dealRecord = zoho.crm.getRecordById("Deals",dealRecordID);
  5. info dealRecord;
  6. //To retrieve the Closing Date
  7. closingDate = dealRecord.get("Closing_Date");
  8. info closingDate; 
  9. //To get the predefined value from the closing month
  10. closingMonth = month.get(closingDate.month());
  11. closingYear = closingDate.year();
  12. //To Format the Month and Year from the Closing Date
  13. picklistValue = closingMonth + " " + closingYear;
  14. info picklistValue;
  15. //Retrieving Current Picklist Values
  16. Dealsfield = invokeurl
  17. [
  18. url :"https://www.zohoapis.com/crm/v7/settings/fields/5725767000003664513?module=deals"
  19. type :GET
  20. connection:"zohocrm"
  21. ];
  22. info Dealsfield;
  23. picklistValues = Dealsfield.get("fields").get(0).get("pick_list_values");
  24. info picklistValues;
  25. //Checking if the Picklist Value Already Exists
  26. flag = false;
  27. for each  option in picklistValues
  28. {
  29. if(option.get("display_value").equals(picklistValue))
  30. {
  31.   flag = true;
  32.   info flag;
  33. }
  34. }
  35. //Adding a New Picklist Value if It Doesn't Exist
  36. if(flag == false)
  37. {
  38. requestBody = Map();
  39. requestList = List();
  40. requestData = Map();
  41. picklist = list();
  42. picklistobj = Map();
  43. picklistobj.put("display_value",picklistValue);
  44. picklist.add(picklistobj);
  45. requestData.put("pick_list_values",picklist);
  46. requestList.add(requestData);
  47. requestBody.put("fields",requestList);
  48. info requestBody + "";
  49. updateField = invokeurl
  50. [
  51.   url :"https://www.zohoapis.com/crm/v7/settings/fields/5725767000003664513?module=deals"
  52.   type :PATCH
  53.   parameters:requestBody + ""
  54.   connection:"zohocrm"
  55. ];
  56. info updateField;
  57. }
  58. //To update the Deal Record
  59. requestBody = Map();
  60. requestList = List();
  61. requestData = Map();
  62. requestData.put("Closing_Month",picklistValue);
  63. requestList.add(requestData);
  64. requestBody.put("data",requestList);
  65. info requestBody + "";
  66. dealreecordUpdate = invokeurl
  67. [
  68. url :"https://www.zohoapis.com/crm/v7/Deals/" + dealRecordID
  69. type :PUT
  70. parameters:requestBody + ""
  71. connection:"zohocrm"
  72. ];
  73. info dealreecordUpdate;


4. Configure the Workflow

Create a custom function by clicking the New Function or associate an existing one to the workflow. In our case, the deluge program has already been written and configured (associated) to the workflow. 

                            
  • Under the workflow actions, select Function and choose the function you created.
  • Ensure that the function is set to run when the workflow is triggered.

Creating a Deal with a Closing Date of January 2nd (Using an Existing Picklist Value)
                                               


Creating a Deal with a Closing Date of April 1st (Adding a New Picklist Value)



The new picklist value, which was not a value previously, has now been added to the picklist.

You can add values to a picklist field using the PATCH Field API. To remove an option from a picklist, use the Update Custom Layout API. Refer to the Sample input to mark picklist options as unused section in the Layouts API documentation.

Cheers!!!

Related Links
Additional Links

    • Recent Topics

    • How to apply customized Zoho Crm Home Page to all users?

      I have tried to study manuals and play with Zoho CRM but haven't found a way how to apply customized Zoho CRM Home Page as a (default) home page for other CRM users.. How that can be done, if possible? - kipi Moderation Update: The option to mark a customized
    • Zoho Projects > Workdrive Integration - Where can you find your files in Workdrive?

      Following the instructions here: https://help.zoho.com/portal/en/kb/projects/integration/zoho-apps/articles/zoho-workdrive-integration#Benefits Put a file in the Documents section of a Project. Then Trying to navigate to the Team Folder in WorkDrive and
    • How to set custom Sales Order numbers

      I am trying to create Sales Orders with data from Jotform submissions. Auto number generation is disabled within Books. Whereas the flow Input recognizes the number (40732 in this example), the Output does not. How can I fix this? I'd like the number
    • Zoho desktop problem when using 2 displays

      I have a Microsoft Surface Pro with a second display attached. When I open Zoho mail desktop and place the window on on the second display and I keep the display attached, everything works fine. HOWEVER: when I then detach the second display (the Zoho
    • Assign Multilpe Owners to a Single Deal and Split Revenue Between the Two

      Hello, In our business, it is common for 2 sales reps to co-manage a deal. As such, I would like to add 2 co-owners to a deal within CRM, and then split the revenue generated by a deal between both owners in our analytics. We are currently tracking this
    • Mix and Match Email Plan

      Dear Zoho Sales Team, I hope you’re doing well. I am currently subscribed to Zoho Mail Premium with one account. However, I would like to modify my plan by adding two Mail Lite (10GB) accounts alongside my existing subscription. Could you please confirm
    • Comprehensive guide to add users

      We've received quite a few questions regarding adding users to the Zoho Sprints workspace. So we decided to address it through a comprehensive post covering the locations (modules or tabs) from which you can add your users. Adding users to your workspace
    • How to monitor hybrid projects?

      Hybrid project management sounds great, but, with projects being run on different project management methods, how can we monitor the overall progress and derive insights from them? If you've got this question as well, Zoho Projects Plus’ dashboards have
    • Learning how to customize templates via code and best practices

      Hi! Our developers team want to learn how to edit our template files safely. The last time we messed with these files our site went down for a day and we had to reconfigure it from scratch. What are the best practices to do this? How can we get a template
    • ULAA threat

      My Sentinal One app just killed ULAA as a threat. I reinstalled, killed it again. I opened ZohoOne CRM in Chrome it worked however it was a least 1 if not 2 backsteps from the version I'm using. Is anyone else having this exerience?
    • Seventh Insight - Organize your data using Modules

      The Wheels of Ticketing - Desk Stories Organize your data using Modules What are Modules? Modules in Zoho Desk are powerful organizational tools that facilitate efficient help desk operations. There are eight standard modules, each designed to manage
    • Argument Mapping went missing?

      How can I access the IDs from the mass action button when argument mapping is unavailable or missing?
    • Properly split form fields across report rows?

      Hi all, I’m trying to split file uploads from a form into separate report rows with a shared Title. Example: Form input: Title + File A + File B Desired result: Row 1: Title + File A Row 2: Title + File B Current Logic: In On Created or Edited and On
    • Email Alerts with Affected Flow Details When Deprecating Modules in Zoho Creator

      Dear Zoho Creator Team, We would like to request an enhancement to the module deprecation process in Zoho Creator. 🧩 Current Limitation: Currently, when a module is deprecated by the Creator team: No email notifications are sent. There is no automated
    • Problem importing TSV file: File contains empty string as column header(s).

      I tried importing a TSV file into Books, and got this message: "File contains empty string as column header(s). Please check the content and try again." I've looked at the file I'm trying to import, and the columns all have labels in the first row. Help?
    • How to Integrate Zoho Books with Xero (No Native Connection Available)

      Hi everyone, I’m currently facing an issue with integrating Zoho Books invoices with Xero, as I’ve noticed Zoho does not provide a native integration with Xero at this time. I would like to ask: What are the common or recommended solutions for syncing
    • UPLOAD A CREATED PDF AUTOMATICALLY

      Using the html header pdf+print button, I have managed to find a way to have a user create a pdf using entered form data. Using the schedule button, I can have a "file uploaded" pdf mailed to someone as an attachment. The missing piece is to be able to add the pdf, created in that html page to a file upload field automatically? Right now one has to save it to computer and then upload it in a FILE UPLOAD FIELD. Any help would appreciated !  
    • Short Custom Order

      Hi Everyone, I have question, i create some report use custom short order like below. But this is just show in development mode.... when i publish to production, it is not showing. And this is just showing in full admin mode. Can setting to show roles
    • is there a way to pass whatsapp message to Zoho CRM lead record?

      so I am trying to implement WhatsApp Native Integration to Zoho CRM. What I really need is to pass Whatsapp Number and whatsapp first message to Zoho CRM lead record. yes I can see the Whatsapp Message inside lead detail record like this but as you can
    • How to use CDN with Zoho wesbites.

      I want to use CDN with my zoho- hosted website. I currently have a dot in website. I would seriously like to utilize CDN such as MAX CDN and cloudflare. Its that am not able to change dns with dot in website. Which is a great catch. Today site speed matters a lot both for business or personal sites. I have lot of visitors from different parts of the world and they suggest to make the website more faster. I would be great if I'm able to use dns or may be cdn.
    • Tip of the Week #58– Stay informed by following threads!

      Want to be notified about the activities happening over a specific thread without getting directly involved there? In shared inboxes, not every message requires your immediate response, but that doesn’t mean it’s irrelevant. Without a clear way to keep
    • Zoho CRM 表示が変わった?

      いつからかわからないのですが、本日(6/3)、表示が変わったことに気がつきました。 皆さんの環境でも変わっているのでしょうか? 当方は Zoho CRM Plus で Zoho CRM Everyone 環境です。 ■タブと項目 タブのレイアウト表示名が「標準」から「スタンダード」になっている。 表示だけなので Deluge とか影響はないとは思います。 ■レコード一覧の項目選択の表示 選択すると青色線で囲いが表示されるようになった。 選択しやすくなって使いやすいです。
    • How do we add Google Analytics code to Zoho Bookings scheduling pages or the thank you page?

      We need to track user activity on individual Bookings' pages and/or the thank you pages? How do we do this?
    • please include option for editing attachment name

      Users need the ability to rename an attachment without having to delete the original and then uploading a duplicate just to rename the doc. We need the ability to edit the name of an attachment directly in zoho. dgdlux
    • Lead Created Time Field

      I don't remember doing it but I must have removed the "Created Time" field from my lead module at some point.  Usually it doesn't let you permanently delete fields like this but it is not in my unused fields so it must have been permanently deleted somehow.
    • Notebook Password Recovery?

      I'm a very happy new user of Notebook, but ... my password has fallen from my memory and I am finding no avenue to reset it. How can I reset it to recover access to my notes? Thanks so much, HOC
    • Unable to create a download link for an uploaded Workdrive File

      Hello, I have some custom logic that is working fine to load image files into a Workdrive folder. I'm not having much success however in being able to then set the file as downloadable and retrieving the download link from my custom logic. My code for
    • Data preservation when a Recruiter Admin leaves the organisation and account is deleted

      I can’t find in the documentation on this topic, so asking here. When the Recruiter Admin employee who has done all the hiring work, e.g. publish job postings, updating email notification templates, changing candidate statuses, writing notes, communicating
    • Zoho Sprints mobile app(Android and iOS) v2.0

      Hello everyone! We’re thrilled to announce that Zoho Sprints Mobile app2.0 is now live. With the newest version of the Zoho Sprints mobile app, we hope to provide a fresh, faster, and intuitive experience for managing your sprints on the go! Whether you're
    • Open-source Zoho API package for Python

      Dear Community, Some time ago I have started working on Zoho API to handle data management in more automated manner than before. Then I have found no relevant materials, except of Zoho API documentation, about how to start. Of course I do not mean it
    • Zoho Writer and Zoho Forms - Merge on update of a form

      Once Zoho Form is submitted it requires a check by the adviser / sales person and adding additional infomation to it before it gets send to the customer for the signature. Unfortuantely there is no option to Merge on update, only on submission of the
    • Journal Entries Do Not Show Multiple Entries to the Same Account

      Another basic accounting function that Books ... Accountants sometimes write journal entries, debiting and/or crediting the same account in the same entry. This is due to the need to record specific activity in an account when we pull reports especially
    • Cookies

      Hey Guys, being a EU based company, we're forced to show the cookie banner, providing easy to read information about the cookies we use and giving the choice to select which cookies the accept. I know in Zoho Marketing Hub, SalesIQ and Sites there are
    • Zoho Sign Custom Domain

      Any plans for Custom Domain?
    • Introducing AI-powered agreement management in Zoho Sign

      Hello! From automating repetitive tasks to enabling smarter decision-making, AI has moved from a futuristic concept to a practical tool for modern businesses. One of the most impactful applications of AI is in agreement and contract management. By leveraging
    • My bank is not in Books

      Hello, I tried to configure bank feeds for my bank, but it doesn't appear in the list of supported banks. Does that mean that i cannot configure feeds at all ? Is there any way to add my bank in the list ? Also, as far as I saw, the list has no Belgian bank : Belfius, BNP Paribas Fortis, KBC,... Thanks for you answer Xavier Liégeois Though Happy Zoho user
    • Updating a contact record's multiple select field

      Hi folks, I have a multiple select field (called Mailing Lists) in Zoho CRM which I wish to set to the text "Weekly Email" I have created a step in Zoho Flow using a Create or Update Contact. In the Mailing Lists field, I put the text "Weekly Email"  (including the quotes) but the flow returns an error requesting a jsondatatype.  I have tried {'Weekly Email'} but I still get the same error. Also tried Weekly Email (without the quotes) How do I format an update of a multiple select field  with Zoho
    • CRM module name capitalisation bug ?

      HI, I''m writing a deluge script from Desk to create a task in CRM. All is good when I deal with a lead, but not when a contact is involved. It took me days to figure it out. It might be a bug. Here is a snippet of my script // Ticket Description taskMap.put("What_Id",{"id":ticketContactId});
    • Can I convert Multiline fields from Plain text to Rich Text?

      I have added several custom multiline fields (Plain text) in the Zoho CRM module "Accounts" before the Rich Text (RTF) feature was released in 2024. Now I am looking for a way to convert them to Rich Text format. Is there a way to do this? The problem
    • Webinar Recording: Maximizing Productivity with Bigin's Mobile Apps

      Dear Biginners, Hope you're doing well! As part of our ongoing Masterclass series, we’ve just completed an exciting webinar that explores the capabilities of our mobile apps. Whether it’s managing deals, communicating with customers, or meeting deadlines,
    • Next Page