Kaizen #176 - Optimizing the Use of Record ID Variables in Zoho CRM Queries

Kaizen #176 - Optimizing the Use of Record ID Variables in Zoho CRM Queries


Hello everyone!

Welcome to another week of Kaizen!


Today, we are back with another one on Queries.
In this post, we will discuss how you can optimize record ID as a variable in Queries.

What are variables in Queries?

Variables are placeholders in queries that take values at runtime. Variables make queries flexible and reusable, avoiding the need to hard-code data.

When you create a query, you can leverage record ID variables in two ways:
  1. Filter By field
  2. Criteria
Each method has its own benefits and considerations. Let's explore them in this post.

1. Using record ID variable in the "Filter By" field

When you use the record ID variable in the "Filter By" field of a query, you streamline the data retrieval process by directly targeting the specific records you need. This method is particularly useful when you want to narrow down your search to specific record based on their IDs. Simply put, this behaves as the Get Record by ID.

Consider an example, where Interested_Product is a lookup in Contacts. Our aim is to get the details of the product that the contact is interested in. We can create a query of type CRM - Module as shown in the following image.

  1. The base module is Contacts, and the related module is Products that is linked via the lookup field.
  2. Choose the required fields you want to retrieve through the query.
  3. In Filter by, select Record ID.
  4. Give the variable to hold the contact's ID in the Record ID field. The format is {{variable_name}}.
  5. The query assigns the ID of the contact dynamically during runtime.
  6. Click Next.
  7. A pop-up asks for the value of the variable.

  8. Input the ID of the contact and click Save.
  9. The response contains the fields that were queried for.

Benefits of having the record ID variable in "Filter by"

  • Efficiency: Directly retrieves the relevant records, reducing the need to sift through unnecessary data.
  • Simplicity: Easy to set up and understand, making it ideal for direct queries.

Considerations

  • Limited Flexibility: May not be suitable for complex queries requiring multiple conditions or criteria.
  • Specific Use Cases: Best used for scenarios where you have a clear and specific record ID to filter by.

2. Using Record ID Variable in Criteria While Fetching Related Records

Using the record ID variable in criteria while fetching related records allows for more complex and dynamic queries. This approach is useful when you need to retrieve related data based on certain conditions or criteria.
Consider an example where you want to retrieve deals of a contact. A deal can have multiple contacts, but you want to fetch only those deals that are related to a particular contact. This case warrants the need for criteria to filter based on the ID of the contact.
Construct a query as follows:
  1. Create a CRM - Module type query for the Deals module.
  2. Choose Contacts as the Related Module.
  3. Select the fields from these two modules that you want to retrieve.

  4. Select "Criteria" and create a variable for the record ID of the contact.

  5. Click Save and click Next.
  6. Give a contact ID for the variable in the pop up.

  7. Click Save and click Next.
  8. You can see the response to the query.

Benefits of using record ID variable in "criteria"

  • Flexibility: Allows for more complex queries with multiple criteria.
  • Dynamic Data Retrieval: Useful for scenarios where the criteria for related records may change based on different conditions.
  • Comprehensive Data: Fetches a broader range of related records, providing a more holistic view of the data.

Considerations

  • Complexity: More suitable for complex queries and requires deeper understanding of how modules are related in Zoho CRM.

Conclusion

Both methods offer their opportunities and challenges in Zoho CRM's data management.
Choosing the right approach depends on your specific needs and the complexity of your queries. For efficient and simple data retrieval, using the record ID variable in the "Filter By" field is ideal.
For more complex and dynamic queries, leveraging the record ID variable in criteria while fetching related records offers greater flexibility.

Experiment with both approaches to see which one fits your use case best.

Share your experiences in the comments or write to us at support@zohocrm.com, and help others optimize their data retrieval strategies in Zoho CRM!

Stay tuned for more posts in this series!

Cheers!

----------------------------------------------------------------------------------------------------------------------------------

      • Sticky Posts

      • Announcing the new SKILL.md for Zoho CRM and the updated OAS repository!

        We are introducing a new zoho-crm skill to make working with Zoho CRM Developer tools (like APIs, functions, widgets, client scripts, queries etc) easier and faster, with the help of AI in your preferred AI harness like Claude Code, Codex, Cursor, VSCode
      • Kaizen #261 : Using Zoho CRM Skill to generate complex COQL queries

        Hello everyone, In the previous Kaizen posts, we introduced the zoho-crm SKILL.md and discussed how it can help you when you are working with Zoho CRM APIs and Client Script. In this Kaizen, we will focus on using the Zoho CRM `SKILL.md` with GitHub Copilot
      • Kaizen #256 - Build an Arrival Readiness Web Tab in Zoho CRM

        Hi everyone! Welcome back to the Kaizen series! In the post, we discuss a use case in hospitality industry: how an Arrival Readiness web tab widget can be used to let reception staff identify and resolve issues before arrival of guests. Use case In the
      • Kaizen #198: Using Client Script for Custom Validation in Blueprint

        Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
      • Kaizen #226: Using ZRC in Client Script

        Hello everyone! Welcome to another week of Kaizen. In today's post, lets see what is ZRC (Zoho Request Client) and how we can use ZRC methods in Client Script to get inputs from a Salesperson and update the Lead status with a single button click. In this

        • Recent Topics

        • #10 India Specifics: GST, GSTIN And E-way Bills

          Meera's new client sent a purchase order, a vendor form, and one line that changed the whole invoice: "Invoices without a valid GSTIN and correct place of supply will be returned unpaid." She had entered her own GST details. The customer's details were
        • Invoke a Widget buttons not opening in Bigin web – open_in missing from response

          Hi, I’m seeing an issue with Invoke a Widget custom buttons in Bigin web. In the Bigin Developer Sandbox, the button works correctly and the custom button response includes: "open_in": "new_tab" However, once the topping is installed in a normal Bigin
        • [Zoho Desk] Follow-up: Show Full Recipient Email Address Display Improvement ?

          Hi Zoho Desk Team, I would like to follow up regarding the recipient display behavior when replying to tickets in Zoho Desk. Currently, when we reply to a ticket, the To, CC, and BCC fields are combined into a single “Recipients” field. In addition, when
        • How to record refund of expenses in zoho books

          Hi, i bought a air ticket and recorded the expense in money out. The ticket was cancelled and the fare (after deducting cancellation charges) was credited back to my bank account directly. How can i record the the above transaction?
        • Multiple subscription plan line items in Zoho Billing quotes

          I run an IT company and sell a lot of licences. A client might have multiple subscription plans including software licences in different categories. A client might have Microsoft licences, antivirus licences, web hosting and maintenance package services.
        • Invoicing multiple expense items as a single line item

                My client would like me to invoice them for multiple expense items on a single line item on an invoice.  Can this be done?  I know I can import billable expenses to an invoice, but I don't know how to show them as a single line item or have them
        • Rename default fields in Zoho CRM

          Hi, I'm setting up Zoho CRM for an Australian company. They are perplexed by the names of the address fields, e.g. "Billing Province" (we would call it Billing State) and "Billing City" (we would call it Billing Surbub). I would like to request that these
        • Do "shortcuts" or symlinks exist in Workdrive?

          I need some kind of link or shortcut to put into folders that point back to original files or folders, is there any way in Workdrive to do this?
        • Contact Lookup Mapping to Custom Module CRM via DataPrep

          Hi DataPrep Team, I'm facing an issue with Contact module lookup mapping to a custom module during the DataPrep-to-CRM migration. As per the documentation, the mapping format for lookup fields should be: <Lookup_Field_API_Name>.<Lookup_Module_API_Name>
        • Zoho ERP | Product updates | August 2026

          Hello users, What’s new in Zoho ERP this month? From Account Registers to new reports, we’ve packed this release with updates worth checking out. Take a look at what’s new and see what’s in store for your business. Introducing Account Registers Account
        • Kaizen #99 - Render Widgets Using Client Script

          Hello everyone! Welcome back to another interesting post. In this post, let us see how you can render Widgets using Client Script. Widgets are embeddable UI components that you can create and add to your Zoho CRM. You can use widgets to perform functions
        • Customer portal: recommended way to scope lookup fields to the logged-in client?

          Hi all, I'm building a customer portal on Creator for our clients (we're a esting lab, so each client has their own sites, contacts and jobs). Planning stage, so I'd rather get the approach right before I build it. The portal forms need several lookup
        • Support for Custom Fonts in Zoho Recruit Career Site and Candidate Portal

          Dear Zoho Recruit Team, I hope you're doing well. We would like to request the ability to use custom fonts in the Zoho Recruit Career Site and Candidate Portal. Currently only the default fonts (Roboto, Lato, and Montserrat) are available. While these
        • Introducing the Zoho Contracts API Collection on Postman

          We are happy to announce that the Zoho Contracts API collection is now available on Postman. You can explore, test, and debug Zoho Contracts APIs without writing application code. What's in the collection Ready-to-use requests for Contracts, Counterparties,
        • Zeptomail in the blacklists

          Hello, I noticed some hard bounces while sending emails, and upon checking the details, I see that we have been added to the blacklists of certain spam lists: Bounce category: Policy failure Reason: ip-issues Message: 5.7.1 Service unavailable; client
        • Add Payment Information (like Bank details)

          I am using the Free plan of Zoho Books. I need to add the bank details/ UPI details on the invoice. How can I do that. I have added the details in the Bank Section.
        • How does Recur setting affect execution time of time based workflow rules.

          When setting a workflow rule based on Date/Time field, the Recur setting does not seem to make sense. If I want the rule to execute at a specific amount of days relative to a date field, what exactly would the recurrence be? That point in time would only
        • Canvas Ungroup is No Longer an Option - Can we Bring it Back?

          You used to be able to ungroup a Group in ZOHO Canvas, but now you have to delete the group and completely start over (re-add the fields, re-place them, regroup them, readjust the group as you want it/reformat) instead of ungroup, move or delete only
        • Reserve Your Spot for the Zoho Recruit India Virtual Meetup

          The Zoho Recruit Meetup India is happening virtually on October 15, 2026, and registrations are now open! This meetup is a chance for Zoho Recruit users across India to come together, catch up on what’s new, learn better ways to use Recruit, and have
        • Account recovery using trusted Zoho applications

          We know forgetting your password can be frustrating. So to make account recovery even simpler and more seamless, we're introducing recovery through Zoho mobile apps; in addition to the existing OTP options using email address or mobile number. Please
        • Introducing Omnichannel Subscription

          Your customers may choose to subscribe through different marketplaces such as Google Play or App Store. As your business expands, managing these subscriptions can become increasingly complex. To make it easier, we are introducing the Omnichannel Subscription
        • WhatsApp Business Message Pricing Update: Effective October 1, 2026

          Hi everyone, Starting October 1, 2026, Meta is updating how WhatsApp Business messages are charged. This guide explains the new per-message pricing model, how message categories work, and what changes for service messages specifically. How Meta charges
        • [Webinar] Automated label merging

          Live webinar on October 8, 2026 | Time: 2 PM IST | 2 PM EDT Hi, Businesses that rely on labels for shipping, inventory, or events often struggle with rigid layouts, disconnected data sources, printing the right quantity, and adapting labels for different
        • zFlow_DateTime

          This kind weird since our Flow is RUNNING FOR ALMOST A YEAR and suddenly, our auto plotting of events on Creator Calendar isn't working. Our team can't afford doing manual thing since we handle lot of service tickets. We suspect that there is something
        • What's New in Zoho Inventory | July & August 2026

          Hello users, The July and August 2026 releases bring a range of new features and improvements across the product. From the Nigeria Edition and Super Admin enhancements to Sri Lanka IRD-compliant invoicing, Loyalty Program Management, and improvements
        • Roles and Privileges in Zoho Mail: Define and control administrative access in your organization

          Imagine a growing organization where the IT team needs to manage users, the support team needs to handle spam settings, and the group admins need to oversee email groups, all without giving everyone full access to the Admin Console. This can be achieved
        • Keep sensitive PDFs protected with Zoho PDF Editor

          PDFs often contain confidential information in the form of financial reports, business proposals, contracts, or forms. Zoho PDF Editor helps you keep that information under control with password protection. With two layers of protection, you can decide
        • Enrich your contact and company details automatically using the Data Enrichment topping

          Greetings, I hope you're all doing well. We're happy to announce the latest topping we've added to Bigin: The Data Enrichment topping, powered by WebAmigo. This topping helps you automatically enhance your contact and company records in Bigin. By leveraging
        • CV Parsing

          Hi guys, I parsed my cvs through Rchilli. What can I use now that they have ended their association with you?
        • Change default "Sort by"

          Is there a way to change the default "sort by" when searching across modules?" in Zoho CRM? Currently the default sort method is "Modified time" but i would like to utilize the second option of "relevance" as the sort by default and not have to change
        • Document Approval Workflow for Non-Users

          Our organisation has not added client users yet to Zoho but we are currently exploring how we can use the document Review and Approval Workflow to send out project updates to clients. While testing, we found that we can only pick users as approvers. Is
        • Zoho Learn - Enable Keep Aspect Ratio by Default

          Hi Learn team, Is there a way to enable "Keep aspect ratio" in Image Options by default? It's really frustrating to have to change this for every image. Realistically, who wouldn't appraciate this?
        • Tip #91 – Let customers join sessions directly from your website with the Customer Widget – 'Insider Insights'

          Hello Zoho Assist Community! When a customer needs remote support, the last thing you want is for them to fumble through an email invitation or navigate to an unfamiliar webpage just to join a session. Every extra step is a moment of friction, and for
        • Profile picture unable to be seen by other colleague.

          Hi, As per title, I'm having problem where my profile pic doesn't show from other colleague account. However, when I uploaded the pic from zoho web, it is showed in my phone apps. Still, other colleagues cant see my profile pic. Please help. Thanks,
        • Mute notifications to followers knowledge base/help center

          Good morning Zoho, We are in the midst of a rebranding. This requires updating all of our knowledge base articles with new screenshots etc. In other words: They are all updated. This means all our customers that follow these articles are spammed with
        • Global Constants / Variables

          It would be great if there were a Global Constant feature. The idea here is for managing constants that are used in multiple Flows and Subflows, but might change over time. The idea is that the change could be made in one place and cascade to all future
        • Item/service subtotal

          Just discovered & really pleased that we can drag to re-order the line items in Sales orders & Invoices, a very nice feature which doesn't seem to be documented? It would be nice to be able to insert a subtotal as a line item to complete this great feature
        • Unable to change alias in the from field on the ZOHO mac app

          I have 1 main mail address, and 3 alias's. on the web mailbox when I create a new email, I can select the alias's from the dropdown in the from field. On the app no dropdown is available.
        • Ask the Experts 33: Ticketing in Zoho Desk

          Every customer interaction begins through one of these channels: email or a phone call, a web form, an instant message, a social media, or a visit to your self-service portal. Bringing these interactions together and managing them in the right context
        • Workflow Automation Not Triggering

          My Zoho CRM workflow sometimes doesn’t trigger when a record is updated, even though the workflow criteria appear to be met. What should I check to find out why the workflow is being skipped?
        • Next Page