Kaizen #91: Dynamic Lookup filters using Client Script

Kaizen #91: Dynamic Lookup filters using Client Script

Hello everyone!

Welcome back to another captivating Kaizen post.  In this post, we will explore the process of implementing lookup filters using Client Script. 

What is a dynamic lookup filter?

 A dynamic lookup filter is a feature that allows you to specify conditions or rules for filtering the options displayed in a lookup field based on the values of other fields or related data . It dynamically adjusts the available lookup options to provide a more targeted and relevant selection for users.  It enables a more intuitive user experience by presenting only relevant choices based on the user's selections. Not by just using the field value on that page, you can also filter the results of the lookup with current date/time, logged-in user, or any custom condition that you can handle using Client Script. You can achieve this in Create, Edit, Detail (Standard) and Clone pages.

You can apply dynamic filters to the following fields using Client Script.
  • lookup fields
  • sub-form lookup fields 

Use Case 1 -Lookup field filter in a form

Consider a Manufacturing company, ABC. The Admin wants to get the list of accounts that have the Account Type as Vendor for the lookup field name "Linked Account" in the Leads module only for standard layout.

Solution
  • Go to Setup > Developer Space > Client Script. Click +New Script.
  • Specify the details to create a script and click Next



 You can filter the list of Accounts visible in the lookup field using the ZDK setcriteria() , so that only the accounts of Account Type Vendor will be visible when the user clicks the lookup icon. 

  • Go to Setup > Developer Space > Client Script. Click +New Script.
  • Specify the details to create a script and click Next .
  • Enter the following script in the Client Script IDE and click save.

  var field_obj = ZDK.Page.getField('Linked_Account');
 field_obj.setCriteria("(Account_Type:equals:Vendor)", { filterOnSearch: true });

You should use the ZDK setCriteria  along with the filter condition, in order to apply filters.

setCriteria() ZDK


You can view the ZDK Documentations in the Library section of Client Script IDE

Here is how the Client Script works.




Use Case 2 - Dynamic lookup filter in a sub-form

Zylker is a health care company. The Admin wants to list the available instruments in the lookup field " Instrument Name " based on the type of Instrument that a service agent selects in the field "Type" only for standard layout. For example, if the service agent selects the Type as "Surgical Instruments", then he should be allowed to choose only instruments of such type in the subform.

Solution:

  • Go to Setup > Developer Space > Client Script. Click +New Script.
  • Specify the details to create a script and click Next .

  • Enter the following script in the Client Script IDE and click save .

var Product = ZDK.Page.getSubform("Product_list").getField("Product_Name");
Product.setCriteria("(Product_Category:equals:"+value+")", { filterOnSearch: true });

  • Here, based on the value the user selects in the "Product Category" , the Product Name will be displayed by picking the Instruments from Product module where the category is equal to the user selection.
  • Here is how the Client Script works.

You should use setCriteria ZDK in order to apply filters for lookup fields in Client Script.

Now, you may wonder what about Lookup filters of the field properties in layouts, when to use them and what is the difference.

Here is the comparison which shows when to use lookup filters in Client Script!
( Please note that this comparison holds good as on June 2023, there may be updates made to below features )

Lookup filters in field properties
Lookup filters in Client Script
 
Use this when you want to apply filters based on entity criteria.
Use this when you want to apply filter based on user selected field value.
 
The filter criteria is specific to the module . i.e The lookup  filter will be the same for all the layouts of the module.

The filter criteria is specific to the layout. i.e The lookup filter will be not be the same for all the layouts of the module. 

Sample use case

You can use this when you want to apply filters where you know the values involved in the criteria like 
Created Date is Today, List the Accounts where the account Type is 'Supplier', Modified by Logged in user.

Sample use case

You can use Client Script when the criteria depends on user selection like to list the available instruments in the lookup field "Instrument Name" based on the type of Instrument that user selects in the field "Type". 

We hope you found this post useful. We will meet you next week with another interesting topic!

If you have any questions let us know in the comment section.
Cheers!



      • Recent Topics

      • Zoho Books | Product updates | March 2025

        Hello users, We have rolled out new updates in Zoho Books to enhance your accounting experience. These include the ability to create workflow rules for manual journals and Multi-Factor Authentication (MFA) for customer and vendor portals. Explore these
      • zet pack not working

        We are using the zet pack command to package our Zoho extension. However, after running the command, the extension gets packed, but the resulting package is empty. We've attached a screenshot for reference. Could you please assist us with resolving this
      • On Duty Requests using API

        Currently we can only do attendance entries using API, we need to make on Duty Requests using API Use Case We are using different on premise devices to track meetings, we want to sync this data with Zoho People Currently we are manually making on duty
      • Owner's Draw

        Example: I have a charge account at ABC Company. During the month I charge one $50 item for my business. I also pick up a $20 item for personal use. At the end of the month, I receive a statement with a balance due of $70 and I want to PAY THE ENTIRE
      • Zoho Forms API

        Is there any way to get all form entry list using API? Looking forward to hear from you
      • Uploads in creator app

        So I have a file upload in the app, I can upload the file to it easily, but can't then download that file, there appears to be no option to?
      • Approval workflow for employee profile form

        Hi, i have a requirement that whenever employee updates certain fields in profile, it should go for HR approval   Specifically, I need to setup below   1. Approval should be triggered only if certain fields are changed. For eg. marital status, education details and address 2. New changes should be reflected only if those are approved by HR... if rejected, changes should not be updated in employee profile 3. Option to attach supporting documents for these changes while submitting for approval 4. Approving
      • How to configure Choice-based Field Rules??

        I have multiple choice, drop down and subform in what i created. However, I can't configure the choice based rules. There's no button link for that. Please help https://forms.zohopublic.com/specialevents1/form/IslandKidsConference2025/formperma/ZCXs
      • Multiple domains,

        Hi I have two domains set in one account on Zoho. One is primary domain and the other is alias. Can I switch these so that alias domain become primary domain? If I make my Alias domain to Primary, will I be able to send and receive emails using this
      • Last activity time is acting like last modified time

        When i edit the description or any field in the potential, account, contact and lead, the Last Activity Time is being updated like the Modified Time. This is messing all workflows and reports and we are unable to track real last time of activities like mentioned in this KB article http://crmkbase.zoho.com/what-is-the-difference-between-record-modified-time-and-record-last-activity-time
      • Prevent invalid entries in forms using Form Field Validations

        Greetings, Forms are crucial for collecting customer information, but inaccurate or improperly formatted submissions can disrupt your business operations. Imagine a phone number entered as random text, an email address missing its domain, or a date field
      • Kaizen #181 - Mandating Subform Data for Blueprint Transitions using Widget

        Hello Developers! Welcome back to another week of Kaizen! This time, we are tackling a common challenge on how to enforce subform data from a different module before allowing a blueprint transition in Zoho CRM Deals module. Many CRM workflows require
      • Make function for repeating code

        Hi, It's me again with my questions... 😅 In my Creator app, there's code that repeats itself in several places. And repeating code necessarily means optimization. So I'm trying to create a custom function to centralize my code in a single place and call
      • Searching for Zoho CRM newbies or users who ...

        I'm looking for people who, like me, want to get started with Zoho CRM and use it better. For mutual motivation. Am I in the right place? Or are there other, more suitable Zoho groups for this?
      • Automation#33: Automate Splitting Names for Existing Contact Records

        An organized directory – who doesn't love one? Previously, we explored how to split contact names into First Name and Last Name for new contacts in Zoho Desk. But what about existing contacts already in your database? This week, we bring you a custom
      • Line chart customization

        Hi, is there any way to draw multiple lines on a single line chart. Now on te x-axis im displaying dates and on the y-axis dispalying total records count. I want to display multiple lines on the same chart. The sample image is attached
      • Change Background in PDF Template

        Background PDF Hi, I want to ask a question. I want to create a background template with my own image. Above is an example that I made, why does the result not fit the A4 format? Like cut off. I used an A4 Portrait image, is there a size error? can you
      • The ability to show fields from subforms when viewing from related list

        Hi there, Currently im only able to display default columns , however when im unable to add the columns/fields from the subform Ive created. below is a field called quantity from the subform. Im not able to search up this field from the manage column
      • Limits on workflow never disclosed, not documents and now being applied. I feel scammed and there is no reply for support.

        Hello everyone, I’m facing a critical issue with Zoho Recruit and would appreciate any insights from fellow users or someone from Zoho. For months, I’ve been receiving daily emails stating that I have reached the maximum workflow custom functions limit.
      • Dialing Microsoft Teams Phone Service via Zoho CRM

        I am using the VOIP option in Microsoft teams for my office phone system. I was hoping to have a way to dial numbers directly from Zoho CRM, but don't see anything in the Teams Integration or in the Telephony integration that will enable this. Does anyone
      • Zoho Projects API v3 - How to format filter critera in deluge

        I'm trying to return the id of a client company in the Zoho Projects API using Zoho Flow and am running into issues about how I format critera in deluge. https://projects.zoho.com/api-docs#clients#get-clients I have several hundred Client Companies, and
      • Bad change: Zoho Notebook Android app requiring Google Play Store login

        I have been a Zoho user for a decade or so, and a One subscriber for several years. There are always areas for improvement, but on the whole, I've been quite happy with it. A big part of my choice to go wtih Zoho is that I value data privacy, and try
      • CRM x WorkDrive: File storage for new CRM signups is now powered by WorkDrive

        Availability Editions: All DCs: All Release plan: Released for new signups in all DCs. It will be enabled for existing users in a phased manner in the upcoming months. Help documentation: Documents in Zoho CRM Manage folders in Documents tab Manage files
      • Add Facebook Pages Triggers and Actions in Zoho Flow

        Hi, We would like to request an enhancement in Zoho Flow to support Facebook Pages triggers and actions. Why Facebook Pages Integration is Important Facebook remains one of the most significant social media platforms for businesses, offering powerful
      • Issue with syncing zoho campaigns with zoho crm

        Hi there, I want to sync both zoho campaigns with zoho crm however i have encountered some issues with this. when clicking manage in zoho i receive this message even though im using the same account and its an admin account. however when i go to zoho
      • Deal Updated by Workflow Rule/Automated Function does NOT Trigger Zoho FLOW!!

        We have multiple Flows setup that are triggered by "Updated Deal" in Zoho CRM. These have worked great. Recently, in Zoho CRM, we set up a workflow rule to update a field based on date/time field. NOW, when the workflow rule triggers and automatically updates a field in Zoho Deals, that does NOT trigger to Zoho Flow. This needs to be fixed! The reason we set this automated function within the workflow rule to update a field is so that could trigger a specific flow within Zoho Flow to do stuff. But
      • Super Admin Logging in as another User

        How can a Super Admin login as another user. For example, I have a sales rep that is having issues with their Accounts and I want to view their Zoho Account with out having to do a GTM and sharing screens.
      • Zoho CRM Roles to Zoho Desk

        I have created my role hierarchy in Zoho CRM, Can i import/sync those roles from CRM to Desk or should i create role hierarchy again in Desk?
      • Preventing auto-redirect to Parent Record on Save...

        Our users often create records from the related list on th left side of the screen. They click the blue "plus" button to create the record. This is handy, but for some modules, or situations, they would like to remain on the record AFTER clicking "Save",
      • Why is my deluge code not executing properly? (New and learning deluge)

        I'm trying to update a sales order number through deluge for an automation I'm trying to build. What is wrong with it? /* replacing SO with SOR for sales order pre-fix */ SO = salesorder.get("salesorder_number"); replace = SO.replaceFirst("SO","SOR");
      • Notebook stacks

        Hello, Are you planning to implement some kind of notebook grouping, similar to evernote stacks? I know that we can group notes inside of the particular notebook but for a lot of us it is not enough I belive. Sometimes that additional layer for organization
      • iOS Widget Not Working

        It appears that the iOS widget is not working, displaying a blank white screen instead of a selected note. I’m using app version 6.5.12 and iOS 18.3.1.
      • Trying to add Products from Accounts subform

        Hi, I have the following script to to add separate Products from a subform in an Account record. There is data in the subform, but I keep getting the error "No records were added". Please advise. string related_list.relateBuyerCriteria(String accountId)
      • Cross module filtering is now supported in CRM

        Editions: All DCs: All Release plan: This enhancement is being released in phases. It is now available in AU, JP, and CN DCs. Help resource: Advanced filters The Cross-module filtering enhancement is now available to all CRM accounts in the following
      • How to control the # of version of files to keep?

        Currently most of the WorkDrive Storage comprise of the many versions of files saved. How do I save some space and reduce the number of version of date or files saved in WorkDrive? Thanks
      • Image Upload Field API get encrypted ID and sequence number

        Hello is there a way to extract the encrypted id and sequence number from image upload fields through the Zoho CRM API? I created a custom script with javascript within Zoho CRM, but I want to extract the encrypted id and sequence number for all my images
      • Richer search experience in CRM with precise results, followup actions, and AskZia

        [Updated on 25 July 2024] This enhancement was in early access. Now, we've started enabling it in a phased manner for customers. It is now available for customers in AU, JP, and CN DCs who are using Enterprise edition or below. [Updated on 10 Dec 2024]
      • Assistance needed in transition if firm is converting into company

        Hello! Our sole proprietor firm is converting into private limited company. I would like to know what needed to be done in zoho books for such case. what are steps that needed to be perform for transition process in our zoho books organization profi
      • Chromium: On open Writer document , Aw Snap

        Opening Writer document does not work in Chromium browser. On open any document, it appears for the moment, then disappear with Aw Snap! Something went wrong displaying this message. Error code: RESULT_CODE_KILLED_BAD_MESSAGE Chromium: Version 136.0.7065.0
      • How to deduct expenses from a payment

        I am trying to take a gross invoice payment in Zoho Books, deduct some expenses from it, and get to the net amount in one transaction. I can do it as multiple transactions but that won't match my bank account entry. Any help is greatly appreciated!
      • Next Page