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

    • add two date range

      Hi, How can I add two date range selections to compare two different column values in a single pivot view? I have attached a snap for your reference.
    • Announcing new features in Trident for Windows (v.1.26.5.0)

      Hello Community, Trident for Windows is here with exciting new features to elevate your email communication and enhance productivity. Let’s dive into what’s new! Open .eml files in Trident. You can now open .eml files directly using Trident. This makes
    • Adjust The max character in Specification Field

      Is there another way to adjust the maximum character limit for the Specifications field in Zoho Commerce? I need to accept responses with fewer than 200 characters.
    • Customize the Sign In And Sign Up in Zoho Commerce

      Is there another way to customize the Sign In and Sign Up in website Zoho Commerce like this i want to customize to edit it like change the "Sign In" word into "Login Zoho Commerce" it is possible or other way to do that?
    • Territories : Deluge and APIs

      I am trying to work out how to filter a deluge query by territory eg "SELECT Total_Amount, Stage, Closing_Date, Created_Time, Deal_Name FROM Deals WHERE Stage in (" + varBaseCriteria + ") AND Territory = 'Territory1'" The problem being that Territory
    • Tidying up messes file system on Site

      I'm been given access to a new site that's been managed by several different people over the years, each with different ways of managing images and files. If I move an image from one folder to another, it shows a missing image icon on the site's page.
    • Move Archive Button in Zoho Mail to Main Toolbar?

      Is there a way to add the Archive Button to this tool bar so I don't have to click the three dots every time?
    • Introducing Bigin 360: Our new pricing edition with increased feature limits and pre-installed toppings

      Dear Biginners Club, Today, we're pleased to launch a brand-new pricing edition called Bigin 360, our highest pricing edition that will sit on top of Express and Premier editions. It's been over four years since our launch, and we're receiving some great
    • URL field display value

      Is it possible to give a URL stored in a project a display value, rather than showing the whole url? I have a lot of projects connected to issues filed on a separate site, each with a distinct URL. For example: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40000
    • need payment link excl. TDS Amount.

      Dear Team Zoho, Kindly generate a payment link excluding TDS amount. So that TDS can be submitted through portal. Thanks & Regards, Arijit S.
    • CRM is very slow now

      CRM is very slow now. Plz check ASAP
    • Access error when running invokeurl

      Hi, I'm running the following code: string standalone.test_api() { LoroToken=zoho.crm.getOrgVariable("LoroToken"); info "LoroToken:"+ LoroToken; headersMap = Map(); headersMap.put("Authorization", "Bearer "+LoroToken ); headersMap.put("Content-Type",
    • Disable Column Freeze in PWA View but Keep It on Desktop — Zoho Creator Reports

      Zoho Creator offers a useful feature to freeze up to two columns in a report view, which works well on desktops. However, our users access the app on both laptops and mobile devices, and freezing columns makes reports nearly unusable on smaller screens.
    • How do I add more space to a note in ‘draw’?

      I’m taking handwritten notes using the draw note, but I don’t seem to be able to scroll down to get more room on the page. How do I make more room to take notes?
    • Overtime per week vs. per day

      In the United States 90% of the states calculate overtime as working more than 40 hours per week. It appears that Zoho People can only calculate overtime per day.  How do we fix this? Here is an example: Mon      8 hours Tues      7 hours Wed      9 hours Thur      8 hours Fri            8 hours -----       Total      40 hours (no overtime) However, Zoho people says 1 hours of overtime because the employee worked 9 hours on Wednesday. Maybe I have something setup wrong in Zoho People?  
    • Add Hebrew Language Support in SalesIQ Idle Chat Handling and Reminders

      Dear Zoho SalesIQ Team, Greetings. We would like to request the addition of Hebrew language support in the Idle Chat Handling and Reminders functionality within Zoho SalesIQ. 🗣️ Background & Use Case Currently, we have successfully configured our Zobot
    • notebook synchronization - problem

      Good afternoon, Since yesterday when trying to create a new notebook, it does not let me and when creating the notes they are not synchronized with the cloud, I think the error may be with the encryption of images because in the pages appears the image
    • Notebook 3.5.0 -- Sort order Name A-Z not working

      Just updated to Notebook 3.5.0 on Windows 10. Sort order by Name, A to Z is backwards, like Z to A. Selecting Z to A still works as expected.
    • Stay organized with chat-to-ticket timers

      Hi there! Ever lost track of a customer’s message? Or found yourself scrolling through long chat threads trying to figure out what’s what? Setting up a chat-to-ticket timer can help. It decides when a reply should stay in the old ticket or create a new
    • New notecards not syncing across devices

      Hi, I'm having the same problem where my notes are not syncing from my Android to my laptop. Please help
    • Please add custom sort in Windows ver. of Notebook!

      Dear Zoho, I love the custom sort (drag and order notes) in the Android version of Notebook, but when I sync onto the Notebook on Windows, the note orders all get messed up because it doesn't support custom sorting yet. This makes it impossible to do
    • Formula to return string "WK 26 - 6.2.25 - 6.8.25

      Here's what I've got but syntatic failure: if(not(isnull(${Deals.GS_Due})), "Week " + Tostring(ceil(dayofyear(${Deals.GS_Due}) / 7)) + " - " + Tostring(month(${Deals.GS_Due})) + "." + Tostring(day(${Deals.GS_Due})) + "." + Tostring(year(${Deals.GS_Due}))
    • Introducing LeadChain in Bigin to sync leads from Social Ads easily

      We're excited to introduce a new topping in Bigin called LeadChain by Zoho Social. LeadChain instantly syncs lead information from social media lead ads to Bigin, making it easier to turn them into customers. It also helps you send conversion data back
    • Templates Access

      There should be an option to grant users access to templates but not allow them to edit/delete templates. In setup there is only one tick option for templates. This will give any user access to view as well as delete/edit. This doesnt make sense as they
    • Generate a Zoho Sign link

      From time to time I get a response "I never received your you e-document for electronic signature" is there a way to generate a Zoho Sign link to share.
    • Power of Automation :: Autocomplete the Project upon Task closure.

      Hello Everyone, A Custom function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it. Requirement:
    • Unable to send email through Gmail

      So I had a custom domain email from Zoho and I was able to send emails from this account through my gmail. 2 days ago I added another user. This user is not able to receive any emails, that's the first issue, moreover, even though I haven't changed anything else other than adding this user, now I am unable to send email through my gmail account with the first user either! I have opened a case with priority "I am stuck, need assistance", haven't got a single reply in about 36 hours. I am unable to
    • "Invalid Credentials(Failure)" when configuring IMAP (Outlook)

      Getting the below response when attempting to configure Zoho mail in Outlook 2016: Notes (what I've done so far): Zoho mail on web client is working with no issues. Though I was certain the username & PW were correct (was using same credentials on web client as I was attempting to utilize in Outlook 2016), just in case, I went ahead and changed my password on the web client and re-attempted Outlook configuration; same error response. IMAP for my email account was enabled on the web client (and POP
    • Custom service report or Zoho forms integration

      Hello, So far the experience with Zoho FSM and the integration with Books has been good, however there are limitations with service reports. As with my business, many organisations send technicians to different types of jobs that call for a different
    • Pre-fill Email field on Zoho Forms

      Hello there, How do we automatically pre-fill the email address field of a Zoho Form from the data that is in CRM? Thanks, Joel
    • Webhook Trigger for New Messages in Cliq Channels

      Hello, I would like to request a feature to enable webhook triggers when a new message is added to a Cliq channel. This functionality would allow us to seamlessly send important information from Cliq to other relevant systems. This webhook trigger can
    • Unable to add subdomain email account under the main email account

      Hi, Is it possible to add a subdomain email account, like sky@agent.rebrightrental.com from the Admin Console of admin@rebrightrental.com in Zoho Mail? Or is that not possible? I want to create at least 3, like oak@agent.rebrightrental.com, bliss@agent.rebrightrental.com,
    • How to delete a large number of emails

      Since no one else seems to be asking this, there must be something in the zoho mail interface that I am failing to see. Not looking for an automatic method. Instead, when I sort email by sender, I want to be able to select all emails from a sender and
    • want to renew my account

      I am not getting email - it seems renewal of account is required. pls check and advise how to renew the account and what would be the charges
    • Mail app and desktop on chrome not syncing properly.

      Yesterday I spent a significant amount of time on the computer moving emails to different folders, and deleting several. This morning, I realized on my zoho mail app it still showed all the emails in the inbox. Nothing had synced. I couldn't find a sync
    • Can't connect to Thunderbird

      Setting up Thunderbird I get an error message: "Unable to log in at server. Probably wrong configuration, username or password". The password and email address are definitely correct as I used them to log in to webmail. My settings are definitely correct
    • Can't receive emails, but can send

      I setup a mail using the domain @shopik.io. I set this up using the correct CNAME record on Namecheap. When I tried to send a test mail from my Gmail account it was not able to send and I got the following error; The response from the remote server was:
    • Unable to send message;Reason:550 5.4.6 Unusual sending activity detected. Please try after sometime

      Hello i'm unable to send any email because i keep getting this error Unable to send message;Reason:550 5.4.6 Unusual sending activity detected. Please try after sometime i have literally sent less than 10 emails today i'm not sure why i'm getting this
    • Partial refunds

      I am trying to process refund for a one item invoice, however the refund is partial: i am getting this error while creating credit note, can anyone share some wisdom about this
    • Tickets are enabled but not showing in zoho desk widget

      Hi, I have a Zoho Desk ASAP JWT widget inside my app. I enabled the KB, tickets, and salesIQ chat (screenshot 1), but only the KB and chat are showing on my app widget (screenshot 2). Can you help? Thank you
    • Next Page