Hello everyone!
Welcome back to another week of Kaizen!
We released the Queries feature sometime back and hope you have tried it out. 
A little gist about this feature before we move on to our post.
Zoho CRM's Queries feature enables dynamic data retrieval from both CRM modules and external services, facilitating seamless integration and informed decision-making. 
Key Components
- Sources: Pre-configured sources like Modules and COQL are available, with the option to add custom sources via REST APIs. 
 
- Queries: Fetch data by selecting modules, writing COQL statements, or specifying REST API endpoints, headers, and parameters. 
 
- Variables: Incorporate variables in criteria, COQL statements, and endpoints to pass dynamic values during execution. 
 
- Schema: Auto-generated schemas define the structure of query responses, with editable paths, field types, and labels for customization. 
 
- Serializer: Utilize JavaScript to manipulate and customize query responses, ensuring data is in the desired format for further processing. 
 
Types of Queries
- Modules: Retrieve records by selecting specific modules and fields, applying conditions to filter data as needed. 
 
- COQL (CRM Object Query Language): Write SQL-like queries to fetch data, supporting complex operations like joins and aggregations. 
 
- REST API: Fetch data from external services by specifying endpoints, headers, parameters, and connections. 
 
With the Queries feature, you can efficiently access and display relevant data within Zoho CRM, enhancing workflow efficiency and decision-making capabilities.
A little insight into Functions before we dive into today's Kaizen! 
Functions, Queries, you get the connection, right? Read on!
Many of us use Functions in Zoho CRM extensively to perform our business logic and customize the way things work in Zoho CRM. You can use Functions in blueprints, workflows, Circuits etc.
Let's say you have a function that gets the employee records from the Employees module. Technically, the function executes an API call or an integration task, and gives a response.
The response can be a string or map(JSON), depending on how the function is written and where it is used. Since functions can be used in many places, the same response format may not be the right one to be used in a circuit or a workflow.
This is where the genie 'crmAPIResponse' object comes into picture!
The power of the 'crmAPIResponse' object
The crmAPIResponse object to be returned in the CRM function should encapsulate the response in a way that it can be used in Queries, Circuit, workflow etc. The details needed are encapsulated as a map. It should include details like crmStatusCode, status, message, body in order to construct the desired format for handling data and customizing the error handling logic.
Let's consider the following example function where we use the getRecordByID integration task.
The response of the integration task contains all the fields in that module, but we want only certain parts of the response JSON and also add custom error messages, to be used in other components like Queries, Circuits, etc,.
Here is the code.
| { leadId = "3652397000018025772"; // Replace with a valid Lead ID 
 // Initialize customAPIResponse map customAPIResponse = map(); 
 // Fetch lead details crmResponse = zoho.crm.getRecordById("Leads", leadId); 
 // Log the raw response for debugging info "CRM API Raw Response: " + crmResponse; 
 // Validate and process the response to include only the required fields if (crmResponse != null && crmResponse.containsKey("id")) { // Extract required fields filteredData = map(); filteredData.put("id", crmResponse.get("id")); filteredData.put("Last_Name", crmResponse.get("Last_Name")); filteredData.put("Email", crmResponse.get("Email")); 
 customAPIResponse.put("crmStatusCode", 200); customAPIResponse.put("status", "success"); customAPIResponse.put("message", "Lead data retrieved successfully."); customAPIResponse.put("body", filteredData); // Include only filtered data } else { customAPIResponse.put("crmStatusCode", null); customAPIResponse.put("status", "error"); customAPIResponse.put("message", "Invalid or null response from Zoho CRM API."); customAPIResponse.put("body", null); } 
 // Return the customAPIResponse return {"crmAPIResponse": customAPIResponse}; 
 } | 
Here, you can see that we have parsed the response of the integration task to get the Last_Name, Email, and record ID using the crmResponse.get("field_API_name") statement and constructed the customAPIresponse object using the customAPIResponse.put("key", "value") statement.
The statement return {"crmAPIResponse": customAPIResponse}; returns the response body as depicted in the previous statements.
Response to the info "CRM API Raw Response: " + crmResponse; statement
| "CRM API Raw Response: {"Owner":{"name":"Patricia Boyle","id":"3652397000000186017","email":"p.boyle@zylker.com"},"$field_states":null,..}}} | 
Response of the return {"crmAPIResponse": customAPIResponse}; statement
| {     "crmAPIResponse": {         "crmStatusCode": 200,         "status": "success",         "message": "Lead data retrieved successfully.",         "body": {             "id": "3652397000018025772",             "Last_Name": "Math",         }     } } | 
Error response
| {     "crmAPIResponse": {         "crmStatusCode": null,         "status": "error",         "message": "Invalid or null response from Zoho CRM API.",         "body": null     } } | 
You can see that we have used the crmAPIResponse object to get only the required keys from the response and constructed a much simpler response.
Finally, to today's Kaizen!
We've established that you can use the crmAPIResponse object to construct responses in a way that's suitable to be consumed at another place like a circuit or a workflow. 
We also know that Queries allows you to have sources of the REST API type to fetch data from various sources. This means that you can have a standalone function that is enabled as a REST API as a source in Queries.
Let's see an example.
There is a simple function that uses the getRecords integration task to get the records from the Employees module.
I have used the crmAPIresponse object to construct a response as shown in the following code.
| string standalone.getRecords() { result = zoho.crm.getRecords("Employees"); response = Map(); response.put("status_code",200); response.put("body",{"code":"success","details":result,"message":"function executed successfully"}); return {"crmAPIResponse":response}; } | 
The response of this function is a string in the crmAPIResponse object as shown in this image.

- Save this function and enable REST API.
  
 
- You can see that the domain is https://www.zohoapis.com. To be able to use this in a Query, register this domain in Trusted Domain.
  
 
- To create a REST API type source, you must add the source. Go to Setup > Developer Hub > Queries > Sources tab.
- Click Add Source and give the details like the name, base URL, headers, and parameters under the Information section.
  
 
- Click Save.
- Go to the Queries tab and click Add Query.
 
- For Source, choose the source you just added.
 
- Under Information, enter the name, API name of the query.
 
- For the endpoint, enter the API Key URL of the function.
  
 
- Enter the parameter name and values in the Parameter field.
 
- Click Add Serializer if you want to serialize the response. In this example, I have serialized the response to include only the Name, Email, and Position fields in the output. The result contains the 'body' object that we returned in the crmAPIResponse object of the function.
 
 
 
 
- Click Save to save the serialization.
 
- Click Next to view the schema of the query. Make changes as required.
 
- Save the query.
 
You can now use this query in Canvas or associate it with Kiosk to solve your business needs.
Let us see how the crmAPIResponse object in the function affects the response of the query.
Query with the function without crmAPIResponse:
Let's consider that the function getRecords() does not use the crmAPIResponse object. In that case, the function returns a response that is a string. This response string cannot be serialized or used elsewhere.

Schema of the query without crmAPIResponse:

Query with the function with crmAPIResponse and serialization:
The same getRecords() function that uses the crmAPIResponse object allows you to construct the response as JSON. You can serialize this response easily and use it in a circuit, query, workflow etc.
You can see here that the response is now a JSON.
Schema of the query with crmAPIResponse:
In conclusion, you can use the crmAPIResponse object in Functions to construct the desired response and use the REST API-enabled function as a source in Queries. 
Leveraging the advantage of the crmAPIResponse object in functions and using it in Queries increases the prospect of solving many more business cases easily and customize more efficiently.
We hope you liked this post and found it useful. Let us know your thoughts in the comments.
If you'd like us to cover any other topic in this series, feel free to comment or reach us at support@zohocrm.com. 
Cheers!
------------------------------------------------------------------------------------------------------------------------------------------------

See Also
- Recent Topics
- How to remove some users in zoho accounts- How to remove some users in Zoho accounts. 
- Forwarder- Hi, I tried to add a forwarder from which emails are sent to my main zoho account email . However, it asks me for a code that should be received at the forwarder email, which is still not activated to send to my zoho emial account. So how can I get the 
- Forwarder- Hi, I tried to add a forwarder from which emails are sent to my main zoho account email . However, it asks me for a code that should be received at the forwarder email, which is still not activated to send to my zoho emial account. So how can I get the 
- DKIM cannot be enabled for the domain as no verified default selector present- Hi Support Team, For Domain DKIM record trying to enable status. but showing error "DKIM cannot be enabled for the domain as no verified default selector present" So, please resolve the issue. Thank you. 
- I can't log in to my account on Thunderbird- I've just had to rebuild my PC (calamitous mess from Microsoft with Win10/Win 11 'upgrade' - they confirmed I had to start with a new build). I have used Zoho mail for years via Mozilla Thunderbird, but now I've had to download the latest version of TBird, 
- Sorten the domain of zoho mail ids- I recently created zoho mail id and am quite excited with the features. But one issue ig nobody wanna type this big zohoaccounts.com I mean silly bold Suggestion zmail.com (sound gmail) (attraction) or some genz words looks cool 
- Weekly Tips : Customize your Zoho Mail Notifications- In a professional context, email communication remains one of the most crucial channels for staying connected and managing workflows. Keeping track of your emails, task updates, or important announcements can be overwhelming—especially if you are juggling 
- How to move emails to Shared Mailbox?- Hello, I created a Shred Mailbox instead of using a distribution group. But I cannot move previous emails to certain shared mailbox. Is it possible move some emails from inbox to shared mailbox? 
- Email task creator when task is updated/marked complete- I am looking for a way to notify the creator of a task in zoho todo when - Task is updated Task is closed Comments entered 1 and 2 are critical, and I cannot find a zoho flow to do this. There is no way that as a manager I will know when someone has completed 
- The attendees will now be redirected to the landing webpage when they exit the webinar, set by the organizer.- Hello All, In the latest version of the Zoho Meeting iOS mobile app (v1.3.16), we have brought in the below enhancements:   Post Webinar Re-direction Revamped exit UI for Webinar Post Webinar Re-direction:  The attendees will now be redirected to the 
- Download API file contents from browser- Hi Team - is there something being planned to be able to trigger file downloads from the browser via a deluge script? i.e. retrieve a file via API, trigger the file download directly from the browser. Or... using the convertToPdf function (https://www.zoho.com/deluge/help/functions/file/convert-to-pdf.html) 
- March 15, 2023: Zoho Docs is discontinued- As of today (March 15, 2023) Zoho Docs is discontinued for all users. We would like to thank our customers for trusting us for so many years! Going forward, we're confident you'll enjoy using Zoho WorkDrive for all your advanced file management and collaboration 
- When using "locations" in zoho books, can you keep the two locations totally separate from each other?- I am looking to add a location but I don't want to intermingle the banking or other accounts. I want that to be like two separate independent branches that use different banking accounts, accounts payable, and accounts receivable. The people who are in 
- Adding a Channel to SalesIQ- I have a client that currently uses Zoho CRM and Zoho Desk. They would like a live chat to place on their website that has a mobile app and chat bots (something like SalesIQ). However, they would also like to have all this work over SMS as well. Does the SalesIQ API allow this? Can I add visitors without them being a visitor on a website? Thanks! Bryan Redeagle 
- DataPrep Bigquery Connection failed- Hello everybody, I want to create a connnection beetwen Bigquery and Dataprep but when I try to connect my project I got this error Loading tables has failed. Table list fetched from the data source expired. 
- How Do I Refund a Customer Directly to Their Credit Card?- Hi, I use books to auto-charge my customers credit card. But when I create a credit note there doesn't seem to be a way to directly refund the amount back to their credit card. Is the only way to refund a credit note by doing it "offline" - or manually- 
- Zoho Flow Needs to Embrace AI Agent Protocols to Stay Competitive- Zoho Flow has long been a reliable platform for automating workflows and integrating various applications. However, in the rapidly evolving landscape of AI-driven automation, it risks falling behind competitors like n8n, which are pioneering advancements 
- Important Features Missing- Hey all I love linkthread, but i am missing some important features. I want to be able to include my Google Tag Manager. I have all the important stuff in my GTM Container: Facebook Pixel, LinkIn Pixel, Zoho Pagesense and so on. So i am able to do retargeting 
- Zoho SignForms: Prefill parameters with spaces render as “+” in the document (even when using %20)- Hello Zoho Sign team, we are using SignForms with prefill parameters passed via URL. Spaces in parameter values are being rendered as “+” in the finalized document—even when we URL-encode spaces as %20. This is critical for us because we prefill addresses 
- Currency selector (based on variable) usage in comparsion- Hi, I've developed a currency selector based on the following topic, and it's working well in pivot tables and charts: https://help.zoho.com/portal/en/community/topic/how-can-i-allow-my-users-to-choose-a-currency-for-the-dashboard I also have a comparison 
- Customize Column in Projects - Default View for Template?- Is there a way to have the columns you'd like to see added to a template? I want my customized columns to show up every single time I create a project from that template. It appears I can customize them in the template but when I create the project they do not transfer over.  Template: See below how the columns in order are : Task, Owner, Status, Assigned, Website URL, Blog H1..etc. When I create a project from that same template it comes out as: Task, Owner, Status, Tags, Start Date, End Date, etc 
- Ask the Experts 24: Analytics, data administration, and mobile experience with Zoho Desk- Hello Everyone! Welcome back to the Ask the Experts(ATE) series! We were so focused on our Autumn 2025 release that we didn't host an ATE session last month. In this month's ATE, we'd like to expand our areas for discussion: we'd like to listen to your 
- Multi-Page Forms in Zoho Creator!- Let’s make long applications easier to handle by dividing them into pages, adding a progress bar, and guiding users step by step through complex data entry. This would be a total game-changer for the user experience and could significantly boost completion 
- Unable to Receive Emails on Zoho Mail After Office 365 Coexistence Setup – Error: 553 Relaying Disallowed- Hello, My domain name is bigniter.com, and I’ve been using Zoho Mail as my email service provider without any issues. Recently, I followed the steps outlined in the Zoho documentation to enable Coexistence with Office 365: 🔗 https://www.zoho.com/mail/help/adminconsole/coexistence-with-office365.html#multi-server 
- Email login error- Login successfully but email page error 
- Shared Mailboxes Disappeared- Zoho Mail users in our company haven't been able to see their Shared Mailboxes for the past few hours. I've checked with App and Web Access, but they can't access them. When I send emails to their addresses, I get no error messages. They're still visible 
- Remote Server is misconfigured- Dear Team, I am unable to use email id as remote server is misconfigured. It would be really great if you could help on this and get this resolved. Thanks & Regard Rohit Gupta 
- why cant i access my email account. it keeps asking me for reverifiying my account by entering my password.- I cant access my account. it keeps asking me for reverifcaton by entering my password. once its entered it asks for it over and over. 
- Free webinar alert on October 16 - Less Complexity, More Security: Workplace + Directory- Hello Zoho Workplace Community! Security and productivity shouldn't be at odds—and with Zoho, they're not. Discover how Zoho Workplace + Directory delivers seamless collaboration with enterprise-grade security, all in one integrated ecosystem. Join our 
- Email Recall Feature In Zoho Mail Which Should Also Work For Outside Organisation Members- Add a feature to recall or undo sending an email within a configurable short time window (e.g., 30 seconds to 2 minutes) after hitting send, similar to Gmail’s undo send. Currently the sent email can not be recall If the recipient is not from within your 
- Workdrive and ChatGPT Team Synced Connectors- Hi, we want to be able to integrate Zoho Workdrive with OpenAI’s ChatGPT Team plan. Google Drive and OneDrive both offer this, zoho please catch up asap. We dont want to have to put our company files in google drive, we want to allow chatgpt Team edition 
- Alias Name (on items) use case in Zoho inventory- Hey, Hope everyone is well. Wondering if anyone can shed some light on the use case of Alias Names on Products in Zoho Inventory? Cheers, Chris 
- Updating an Invoice Line Item's Discount Account via API Call / Deluge Custom Function- I need help updating an invoice line item's discount account via API. Below is a screenshot of the line item field I am referring to. Now the field to the left of the highlighted field (discount account) is the sales income account. I am able to modify 
- Send e-mail with attachments- Dear Zoho, How is that possible in Zoho Flow to send an e-mail with attachment?  Just a simple example: Zoho Flow checks my Zoho mails and if the conditions starts the trigger then I would like to send an email with the original email's attachment. Any idea? BR, Adam 
- How to I get checkboxes on a subform to update via deluge- Hello, would someone be able to tell me what I'm doing wrong here? I am trying to take the contents of a Deals subform and add them to an invoice then update the checkbox on each row so that 'add to invoice' is unticked and 'invoiced' is ticked. The output 
- CRM Related list table in Zoho analytics- In Zoho Analytics, where can I view the tables created from zoho crm related lists? For example, in my Zoho CRM setup, I have added the Product module as a related list in the Lead module, and also the Lead module as a related list in the Product module. 
- Cadences- I have just started using Cadences for follow-up up email pipeline. Is it just me or do you find the functionality very basic? For example, it will tell me (if I go looking for it) if someone has replied to a follow-up and been unenrolled; but it won't 
- Add Webhook Response Module to Zoho Flow- Hi Zoho Flow Team, We’d like to request a Webhook Response capability for Zoho Flow that can return a dynamic, computed reply to the original webhook caller after / during the flow runs. What exists today Zoho Flow’s webhook trigger can send custom acknowledgements 
- Your bot just got smarter: AI-Powered routing that reads between the lines- What if your bot could tell the difference? Between a visitor who just needs a quick answer, someone actively comparing options, and a frustrated customer one click away from leaving? Most bots can't. They deliver the same response to everyone, missing 
- Tips & tricks: Make SalesIQ automations work for you- Every day, thousands of visitors land on your website. Some browse, some buy, and some leave without a word. But, wouldn’t it be great if you could automatically know who’s interested, engage them at the right moment, and never miss a lead, and all this 
- Next Page