Dynamically Update Picklist Values in Zoho CRM Workflows

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


      Zoho Campaigns Resources


        • Desk Community Learning Series


        • Digest


        • Functions


        • Meetups


        • Kbase


        • Resources


        • Glossary


        • Desk Marketplace


        • MVP Corner


        • Word of the Day


        • Ask the Experts


          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

                                  • Change DKIM From 20248 Bit Key to 1024 Bit Key

                                    I am having issues trying to change the Bit Key in DKIM from 2048 to 1024 so that it works with my Shopify Account. I can only find information on how to configure this when the Domain Key is added, but I couldn't find any details on how to change it
                                  • How to Add Custom Sections in the Product Page?

                                    Hi Zoho team, I’m currently using the Tranquil theme on Zoho Commerce and I have a question regarding the product page layout. Right now, under each product, I can see expandable sections like Product Details and Specifications. I’d like to add two additional
                                  • Introducing ICR in Zoho CRM: Transform your printed text into digital data

                                    From writing on papyrus in the ancient times to creating a humble record in your CRM, the world may have evolved with how it used to record data, but data entry as such has not been simplified. It is still a repetitive and arduous chore on which businesses
                                  • Can you change the width of a template, and/or the size of images we upload to the template?

                                    my images look good in preview, but are then skewed when sending email. Also, are image sizes "fixed" by which template is being used? Thanks in advance. CV
                                  • Update Date field using a custom function

                                    Hello, In Zoho FSM, Equipments module, I created the following custome fields for tracking the calibration of the eqipments: "Calibration Required"; type: Checkbox; API Name: "Calibration_Required__C" "Calibration Interval (Days)"; type: Number; API Name:
                                  • Zoho CRM API, Python SDK v7 Quoted_Items

                                    Hello. How do I use this SDK to retrieve the Quoted_Items from a Quote and downstream the items in a Sales Order I can see references to a constant INVENTORY_MODULES_ITEMS = ["invoiced_items", "quoted_items", "purchase_items", "ordered_items"] But I cannot
                                  • Zohoのシステムについて

                                    ここで提供しているofficeソフトが使いたくて質問するためにユーザー登録をしました。企業を対象として事業展開されているようですがzohoのシステムがよくわかりません。writerやsheetなどのソフトを利用してもかまいませんか?また利用するときの費用はどうなっているのかとか組み込まれているbasicについての資料とか、要望事項を記してくださいと書かれてあったりとか質問したいことがたくさんありますがこうした質問が許されているのかもわかりません」 ここの書き方もよくわかりません
                                  • Email de outra pessoa ja associada ao meu dominio

                                    Tenho um dominio e está falando que o email da pessoa ja está associada ao meu dominio
                                  • Pin multiple columns and adjust column widths in CRM subforms

                                    Hello all, Subforms act as secondary forms or tables in which you can associate multiple line items to a primary record and thereby ensure more structured and comprehensive data organization. We've made some recent enhancements to subforms. Here's what's
                                  • MULTI-SELECT LOOKUP - MAIL TEMPLATE

                                    Dear all how are you? We need to insert data from MULTI-SELECT LOOKUP in a email template, but I can't do that, when I'm creating the template I can't find the field to insert it. is there any solution? PVU
                                  • Can you please let us know how we can use Zoho for multi store?

                                    Hello Team, Can you please let us know how we can use Zoho for multi store because when we connect our plugin to Zoho and we create a product and then on another store when we create product with same name then product already exist error occurs, so how
                                  • On create of Amc module get sub form data of last row and update in Schedule Vist End Date field in zoho crm

                                    @Iswarya B G @Bhoomi Joshi @Abinaya Praveen @Ishwarya SG @Haiku Technical Support On create of Amc module get sub form data of last row and update in normal module field Schedule Vist End Date field in zoho crm
                                  • Announcing Early Access to "Zoho CRM for Everyone" — A new and exciting update to Zoho CRM

                                    We are delighted to announce an Early Access to Zoho CRM for Everyone— a truly democratic approach to managing a CRM, gift-wrapped in an exciting and intuitive user interface. Here, multiple teams across an organization can coordinate among each other
                                  • How do I create a time field?

                                    I want a field that only records time. I can only see how to create a date-time field. If I do that and enter a time, without a date, nothing is recorded. If I create a number or decimal field, I cannot use it in time calculations. All I want is a field
                                  • Magento 2 as data source for Analytics

                                    I see that Shopify is in Beta as a data source, any change that Magento 2 is in the works? We currently use Metrilo to parse our eCommerce data for marketing and would love to keep that inside our Zoho ecosystem. Thank you!
                                  • Zoho Finance Issue in Deals (ZOHO CRM)

                                    I create almost all estimates/Invoi in Zoho Finance when I convert a lead into a deal or a contact into a deal. But in the Deals section, when I click on any person’s deal, I don’t see the estimations or invoicing from Zoho Finance at the end. May I know
                                  • Invalid OAuth Token When Using Zoho CRM API with Postman

                                    We're in the process of integrating Zoho CRM with our Django backend and currently testing the API endpoints via Postman. I've forked Zoho's official CRM REST API collection in Postman for this. Steps Taken: Created a Self Client via Zoho API Console:
                                  • Restrict card movement in Kanban View

                                    Hello everyone, I’m wondering if there’s a way to prevent users from moving Deal cards in the Kanban view when grouped by Stage. On the Deal details page, I’ve implemented several validations to ensure users cannot change stages until all conditions,
                                  • Everything you want to share — in ONE link

                                    Hey everyone, Say hello to our very own link in bio tool – Linkthread is designed to create a single customizable link that contains everything you want to share with your audience on social media. Welcome to the Linkthread Community! What's Linkthread?
                                  • What is the difference between a template and a snippiet

                                    Hi there, I am currently working on optimising our service desk and improving the consistency of our responses. I have come across two tools that appear to help do this, templates and snippets. I was wondering what the similarities and differences are
                                  • Is there a way to set up templates for commonly occurring issues on Zoho Desk

                                    Hi there, We have recently migrated our service desk over to Zoho. I was wondering if there is a way we can set up custom templates for specific requests that we commonly get from our customers. Example: Customer often requests a password reset. There
                                  • Can I add Conditional merge tags on my Templates?

                                    Hi I was wondering if I can use Conditional Mail Merge tags inside my Email templates/Quotes etc within the CRM? In spanish and in our business we use gender and academic degree salutations , ie: Dr., Dra., Sr., Srta., so the beginning of an email / letter
                                  • Dynamic user applications for CPQ?

                                    Hi, I've been enjoying getting to know CPQ, the Product Configurator and Price Rules components have been very useful, albeit with some issues. I have noticed that I don't have the power to decide which level of sales staff has permissions when it comes
                                  • Automate Zoho Meeting Creation via Blueprint (Leads & Accounts)

                                    I need help automating Zoho Meeting creation during a blueprint transition in both the Leads and Accounts modules. Requirements: Triggered via blueprint Read meeting start time (DateTime field) and internal participants from CRM Create Zoho Meeting via
                                  • Forecast UI improvements

                                    Hi I have two improvement requests for the UI in the Forecast function. Can you add the ability to reorganise the Pipeline, Committed and Best Case columns on the Forecast? I thought they were in alphabetical order, so we renamed them so that we could
                                  • Cómo guardar datos de subformularios en filas individuales en Zoho Sheet o Google Sheets

                                    Hola comunidad, Estoy trabajando con un formulario principal en Zoho CRM llamado Clientes, el cual incluye un subformulario llamado Productos (máximo 3 productos por cliente). En el formulario principal tengo los siguientes campos: Cliente Teléfono Correo
                                  • ZOHO BOOKS EXPERT

                                    We are planning to migrate from Quick Books to Zoho Books, and are looking for a professional with experience in migration to Zoho Books and the setup of Zoho Books. Currently, we have two companies and two Quick Books accounts, and we want to integrate
                                  • Currency fields and decimal places in CRM email templates

                                    Hi, How do I get more than the standard 2 decimal places showing in a Currency field, on an email template? In the Layout for my Currency field, it is set to 6 decimal places. I want to show up to 6 places in the email template (unrounded). See attached
                                  • Estimating Project Costs in Zoho Projects – Based on Hours and External Costs

                                    Hi everyone, I'm currently setting up a project in Zoho Projects and working on implementing a budgeting structure. I’ve already enabled cost tracking based on hours logged to tasks, but I’m looking to expand this to estimate total actual costs, based
                                  • Assistance Required for Zoho Bulk Import Error

                                    Hi, I am currently attempting a bulk import in Zoho with a small batch of records to test if the import will be successful. However, despite matching all fields correctly, I continue to encounter the following error: "Not a standard user: Prospect Owner."
                                  • Invoice status on write-off is "Paid" - how do I change this to "Written off"

                                    HI guys, I want to write off a couple of outstanding invoices, but when I do this, the status of the invoices shows as "Paid". Clearly this is not the case and I need to be able to see that they are written off in the customer's history. Is there a way
                                  • Sending possible. Receiving not possible.

                                    We are not receiving mail in our company email. Could you please solve this. It has been recurring and I want it to be resolved once and for all. Please help.
                                  • Print a price list or price book

                                    Hi Community. Am I right in concluding that Zoho has no functionality to print a price list from either Zoho CRM, Zoho Inventory or Zoho Books? I won't get stuck on the fact that Zoho doesn't sync price books between Zoho CRM and Books/Inventory (more
                                  • 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
                                  • Marketing Automation Emails Going to Spam

                                    Google is trapping all the marketing automation emails in spam. My domain has a perfect reputation and it looks like Zoho has a low reputation which is sending it to spam. When I pull the email out of spam and click on a link in the email, I get this
                                  • Page Break

                                    Is there a way to set page breaks in Zoho Sheet. I couldn't find anything about it on the board.
                                  • Zoho Projects API - Searching Projects by Custom Field

                                    Hi How can I search all projects by a custom field? I can confirm that using the search_term parameter as documented here does not work for me: https://www.zoho.com/projects/help/rest-api/search-api.html#alink3 My search term is "22424", which corresponds
                                  • Can we have Backorder Management ?

                                    Can we have Backorder Management ?
                                  • How to see history on Bulk send of Customer Statements

                                    Hi, We bulk send statements to customers every month via Books - every month we have customers emailing requesting a statement. Currently I have no visibility on if a customer was sent the statement or not and if our process is being followed or overlooked
                                  • A few Issues when using "Pay Bill via Check"

                                    We have quite a bit of issues with how paying for Bills via Check works. Would love some feedback from the Zoho team in case we are doing something incorrectly. 1. When we go from a vendor and select "Pay Bill via Check" option, we see ALL the outstanding
                                  • Next Page