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

- Input the ID of the contact and click Save.
- 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:
- Create a CRM - Module type query for the Deals module.
- Choose Contacts as the Related Module.
- Select the fields from these two modules that you want to retrieve.

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

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

- Click Save and click Next.
- 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!
----------------------------------------------------------------------------------------------------------------------------------

See Also
Recent Topics
Gantt Chart - Zoho Analytics
Are there any plans to add Gantt Charts capabilities to Zoho Analytics?
Displaying related quotes in sales order and back
Hi, My colleague liked to see to which sales orders, the quote has been converted. Quote shows Invoices, but not SO. Same, they would like to see the quotes in the sales order, as they can see invoices, packages, shipment, How can we achieve this ? Thank
Tip of the Week #71–Auto-move incoming messages to the right inboxes with keywords
We all know that customer-facing teams, especially your sales and support teams, can’t afford to miss even a single customer conversation. But sometimes, sales queries or support requests can easily get lost in a crowded inbox or even end up in the wrong
Clearing Fields using MACROS?
How would I go about clearing a follow-up field date from my deals? Currently I cannot set the new value as an empty box.
Migrating a Zoho Forms form into Zoho Creator
Hi, How can I migrate my Zoho Forms form into Zoho Creator? Thanks. Truly, Emad
Is there any way to recall an email sent using Zoho CRM?
If an email is sent using Zoho Mail, there is a recall option/functionality that is available to the sender. Is there any way to recall an email if it was sent using Zoho CRM? I can't seem to find that option. Any help would be appreciated.
Quick Create needs Client Script support
As per the title. We need client scripts to apply at a Quick Create level. We enforce logic on the form to ensure data quality, automate field values, etc. However, all this is lost when a user attempts a "Quick Create". It is disappointing because, from
is it possible to add more than one Whatsapp Phone Number to be integrated to Zoho CRM?
so I have successfully added one Whatsapp number like this from this User Interface it seems I can't add a new Whatsapp Number. I need to add a new Whatsapp Number so I can control the lead assignment if a chat sent to Whatsapp Phone Number 1 then assign
Problem with reports due to "Connected" items change - Yes this IS a problem
Now that the change has been made to use "connected" items I can no longer run the reporting I need in CRM. I should be able to start with Deals as the parent, connect down to the Account (Account_Name) on the deal as the child, then to any child items
Zoho sheet desktop version
Hi Zoho team Where can I access desktop version of zoho sheets? It is important as web version is slow and requires one to be online all the time to do even basic work. If it is available, please guide me to the same.
Introducing notifications in the vendor portal
Imagine this: You're a recruiter working with multiple vendors on a high-volume hiring project. You’ve just updated a job description after a last-minute change from the hiring manager. One of your vendors, however, is still working off the older version
CRM limit reached: only 2 subforms can be created
we recently stumbled upon a limit of 2 subforms per module. while we found a workaround on this occasion, only 2 subforms can be quite limiting in an enterprise setting. @Ishwarya SG I've read about imminent increase of other components (e.
LESS_THAN_MIN_OCCURANCE - code 2945
Hi I'm trying to post a customer record to creator API and getting this error message. So cryptic. Can someone please help? Thanks Varun
How to update "Lead Status" to more than 100 records
Hello Zoho CRM, How do I update "Lead Status" to more than 100 records at once? To give you a background, these leads were uploaded or Imported at once but the lead status record was incorrectly chosen. So since there was a way to quickly add records in the system no matter how many they are, we are also wondering if there is a quicker way to update these records to the correct "Lead Status". I hope our concern makes sense and that there will be a fix for it. All the best, Jonathan
Analytics for notes created
Is there a way I can see how many notes were created per day? Via reporting or analytics?
Add Custom Reports To Dashboard or Home Tab
Hi there, I think it would be great to be able to add our custom reports to the Home Tab or Dashboards. Thanks! Chad
No TDS Deduction
In some of our case, where we are reselling items at the same rate we purchased. In this scenario, Indian IT Law has a provision to request customer not to deduct TDS if the transaction value is same. TDS is paid by us (intermediary reseller) before we
Cannot update Recurring_Activity on Tasks – RRULE not accepted
Hello, I am trying to update Tasks in Zoho CRM to make them recurring yearly, but I cannot find the correct recurrence pattern or way to update the Recurring_Activity field via API or Deluge. I have tried: Sending a string like "RRULE:FREQ=YEARLY;INTERVAL=1"
Add image to report...
Greetings, I send a weekly color coded report via Creator email. I would like to add the legend somewhere in the report. Header, footer where ever. I have the legend saved on Google Drive and can access it via shared link. Sure someone has wanted to add
More controls for User Fields in CRM
Dear All, We are here with a minor but crucial enhancement to the user fields—now set accessibility permissions to the records for user field. User field allows you to extend co-ownership of records to your peers. You can collaborate with them for certain
Calls to accounts rather than leads or contacts?
So..... We have a dilemma and I'm hoping someone has encountered this before and figured out a fix. We have just migrated to Zoho. It's great.....expect for how "Calls" are handled.... We are B2B. We do not use the leads module. A "Lead/Prospect" for
Image Upload Field | Zoho Canvas
I'm working on making a custom view for one of our team's modules. It's an image upload field (Placement Photo) that would allow our sales reps to upload a picture of the house their working on. However, I don't see that field as a opinion when building
Power of Automation :: Automated 'Delayed & Closed' Status Update Based on Due Date
Hello Everyone, A custom function is a software code that can be used to automate a process and this allows you to automate a notification, call a webhook, or perform logic immediately after a workflow rule is triggered. This feature helps to automate
Lead Blueprint transition in custom list view
Hi, Is It possible to insert the Blueprint transition label in a custom Canvas list view? I am using Lead module. I see the status, but it would be great if our users could execute the Blueprint right from the list view without having to enter the detailed
Range names in Zoho Sheet are BROKEN!
Hi - you've pushed an update that has broken range names. A previously working spreadsheet now returns errors because the range names are not updating the values correctly. I've shared a video with the support desk to illustrate the problem. This spreadsheet
Has anyone integrated SMS well for Zoho Desk?
Our company does property management and needs to be able to handle inbound sms messages which create a ticket for Zoho Desk. We then need to be able to reply back from Zoho desk which sends the user an sms message. This seems like a fairly common thing
populate email address and name in zoho desk?
Is it possible to populate the email address and name in the zoho desk widget? We only use it in the context of an authenticated user, so we already know the user's name and email. Thanks,
Are there default/pre-built dashboards in Zoho Desk?
Hi, I am looking for some pre-built dashboard templates in Zoho Desk, similar to what we can find in CRM/Projects, etc Thank you
SAP S/4 HANA to CRM Integration - change the SAP Client ID
Hi I am trying to push the business partners from SAP S/4 HANA to ZOHO CRM module. The SAP Client ID is 421 in my case....kindly let me know how do I specify the sap client because it's a dropdown with specific values as of now. Thanks Ravi Aswani
Enable Locations for Expense
Hi, please enable Locations (ex Branches) for Zoho Expense so that there is consistency between this app and Zoho Books. Thanks in advance.
Adding branded signature to tickets reply
Hi, i am unable to figure out how to add signatures with logo to tickets reply. please advice .
Zoho Marketing Automation 2.0 - Landing Page function not working
Dear Zoho Team, I am working on implementing Zoho Marketing Automation 2.0, and am now looking into the section "Lead Generation". If I open the "Landing Pages" section, I immediately get an Error code: Error: internal error occurred. Can you help me
Zoho Mail Android app update: Manage folders
Hello everyone! In the latest version(v2.9) of the Zoho Mail Android app update, we have brought in support for an option to manage folders. You can now create, edit, and delete folders from within the mobile app. You can also manage folders for the POP
How to share ticket numbers across different ticket types
I'm running an event and have three different ticket types. Add on Event + Main Event - Early bird Main Event only - Early bird Add on Event only - Early bird And Standard class - shown but not available until early bird finishes Add on Event + Main Event
How to keep track of bags, cans, drums of inventory?
We buy and sell products that are packaged in bags 🛍️, cans🥫, drums🛢️, etc. with batch numbers. When we get a shipment of one of the products, how do we track we received (say) 10 cans each of 5L of a product and maybe we received 10 cans of another
Adding Social Media Buttons to Basic Campaigns
Hi, I'm quote new to using Zoho Campaigns and I can't work out how to add Social Media Buttons into my basic campaign? In MailChimp there's a button that brings the icons into your campaign for you. I've tried adding the social media icons as 'buttons' in Zoho but it's not looking great. Can anyone help? Thanks!
Hide Inactive Social Sign-In Providers from Login Screen
Hello Zoho Team, We hope you are doing well. Currently, Zoho One allows admins to configure security policies and enable or disable Social Sign-In options for third-party providers such as Apple, Google, Microsoft, LinkedIn, Yahoo, Twitter, Facebook,
[Free Webinar] AI Agents in Zoho Creator - Creator Tech Connect
Hello Everyone! We welcome you all to the upcoming free webinar on the Creator Tech Connect Series. The Creator Tech Connect series is a free monthly webinar that runs for around 45 minutes. It comprises technical sessions in which we delve deep into
Download All Attached Files
It would be extremely useful to have "download-all" functionality for downloading files attached to a task, subtask, comment, forum post or hosted in the "Documents" section etc. We've instructed our users to zip multiple files prior to uploading, but of course they forget all the time. Having to download lots of files one-at-a-time off a comment or task wastes a lot of time.
Ship via Carrier Not Working Since Commerce Update
Since the recent update to the Commerce platform, I can no longer use the ship via carrier function. It will take me to the address screen and let me verify them but when I go to save and move tot he next screen it will not do anything. This is happening
Next Page