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
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
How to find (total) profits per item in Zoho inventory or Zoho Books
Hi, I would like to find out how to generate a report that has Item/ Cost Price/Sales Price (total)/Profit (total)/Margin The current sales reports has the total qty sold and the sales price but does not show the profits. Can i check how to do it? Similar
3/26(水)開催|5名限定 課題解決型ワークショップイベント Zoho ワークアウト開催のお知らせ
ユーザーの皆さま、こんにちは。Zoho ユーザーコミュニティチームの中野です。 3月開催のZoho ワークアウトについてお知らせします。 ※定員に達したため、受付を終了しました。 ━━━━━━━━━━━━━━━━━━━━━━━━ Zoho ワークアウトとは? Zoho ユーザー同士で交流しながら、サービスに関する疑問や不明点の解消を目的としたイベントです。 Zoho サービスで完了させたい設定やカスタマイズ、環境の整備など……各自で決めた目標達成に向け、 Zoho Champion や、他の参加者と同じ空間で作業を行うことが可能です。
Page - Gauge - Target Values
Is there a way to make the Target and Maximum values say a formula or query? For example, total sales for the month = 109 and I want to make my gauge today's percentage.
Continue after error for each loop on invoke url
Hello. I'm trying to upload files to workdrive using invokeurl. It goes through a list of urls using for each. Sometimes the file is larger than 5mb. The whole workflow stops in that event. I'd love a work around to upload larger files, but I don't think
Error AS101 when adding new email alias
Hi, I am trying to add apple@(mydomain).com The error AS101 is shown while I try to add the alias.
【開催報告】東京 ユーザー交流会 2025/3/19 エキスパートユーザーがZoho サービス活用における基本から応用までのノウハウを伝授!(CRM / Marketing Automation)
皆さま、こんにちは。コミュニティチームの藤澤です。 3/19(水)に東京ユーザー交流会を開催しました。当日は22名のユーザーの皆さまにご参加いただきました。本投稿ではその様子をお届けします! 当日の登壇資料などもこちらで共有しますので、参加できなかった皆さまもぜひご参照ください。 Zohoサービス活用事例セッション: Let's 活用!Zoho CRM レポート機能 2024年度のZoho Championである@松井 邦夫 さん(Zotion)にご登壇いただき、これまでのご経験をもとに「CRMのレポート機能」についてご解説いただきました。
setting owner of note when adding via deluge
My organization has requested the ability to mass update the notes related list in the deals module. Since this can't be done with the mass update feature, I created an update "notes single" line field and created a workflow rule that triggers a function
Permission Update Failed
Dear Sir, I have downgraded from the trial paid plan to Free Plan. I am logged in as CEO - Administrator and trying to change the profile permission but getting error - Permission Update Failed. Please see the screenshot. In most of the pages I am getting
Circuite fail because www.zohoapis.com:443 refuse conection
Is anyone else experiencing this issue? A few weeks ago, I started having issues with circuits failing due to www.zohoapis.com:443 refusing the connection. The error message is quite clear and points to a problem on Zoho's API server, rather than with
Ability to re-order Workflow Rules
We really need the ability to re-order workflow rules within departments. Either the ability to drag/drop them into a different order or something.
Forwarding email into Desk - DMARC errors
Hi, Our email domain is hosted through Exchange Online (Office 365). Customers email support@ourdomain.xyz which is delivered to Exchange. Exchange rewrites the TO email header to the email address associated with our Zoho Desk (support@ourdomain.zoho.xyz).
Auto-sync field of lookup value
This feature has been requested many times in the discussion Field of Lookup Announcement and this post aims to track it separately. At the moment the value of a 'field of lookup' is a snapshot but once the parent lookup field is updated the values diverge.
Location functionality now deletes bundle information if changed
With the introduction of Locations, we are experiencing several issues. 1. When bundling an item, the 'default' is to the organisation, not a location. This is not a significant issues, other than when you change the value, any batch tracking information
ZOHO DESK ヘルプセンターの言語選択メニューの表示方法
ZOHO DESK のヘルプセンターを構築し、多言語化設定をしました。 顧客のヘルプセンター画面右上に言語選択メニューが表示されないため、弊社の契約先会社に問い合わせましたが、「通常は多言語化をオンにすると表示するためCSS を触り過ぎではないか」 という指摘のみでした。 試行中ですが表示できません。 何か要因となる情報をお持ちの方がいましたらご教授いただけますと幸いです。 ↓の赤枠を表示したいのですが、表示できません。
I live a webhook of zoho flow and I don't know how to respond with the following json {"fulfillmentText": "Text"}
dialogflow sending me data to the webhook, I do searches in my zoho application and at the end of my flow I need to give this answer to dialogflow ... I don't know how to configure the webhook response! how is it done? This is the answer I need to send
Using Linkedin as 'Unique Identifier ' for Duplicate Management for Candidates and Contacts in Zoho Recruit
Quick hats off to Zoho Recruit on the functionality of Unique Identifier ' for Duplicate Management for Candidates and Contacts in Zoho Recruit. I recently added the ability to manage duplicates based on Linkedin profile. Candidates' and Contacts' email
Sales Returns - Repairand Return
Hi Inventory Team, I'm working with a client on an Inventory implementation project and they have shared this use case with me. Some items may be returned by the customer, then returned to the vendor for repairs, received from the vendor and shipped back
Inserted Records not showing in Kanban view
When insert a new record into a report from a workflow, it doesnt show in KANBAN view. When i view the report in a regular list view, the records are there. If i edit the record (while in list view) and then update it at all (even if i dont change anything,
Client scripts for Zoho Books ?
Good day everyone, I am looking for a way to be able to interact with the Quotes and Invoices as they are being created. Think of it like Zoho client script in Zoho CRM. But for the life of me I dont see a way to do this. The issue with having function
Multiple Admin accounts
We recently moved Admin access to our original recruiter (who left) and owner ship of the admin account is set to our CEO. I've asked to also be given admin access so he is not a limiting resource but he/we can't seem to find that out. He recently upgraded
Zoho Desk Invite
I'm trying to send an invite via Zoho Desk to the email nwc.hd@telecare.com.sa using my account in Zoho desk rmsh7777.rs@gmail.com but the invitation or email is no received. I need your kindness to activate the account, please.
Cannot read properties of null (reading 'className')
Hello, I'm attempting to integrate the Zoho desk chat widget. It loads visually on most pages, but at some point, it throws this error and it never appears: Cannot read properties of null (reading 'className') Here is the full trace: floatbutton1_hXdnKUp…f6FPihRNT_T47_.js:1
Zoho Support / Microsoft Outlook integration
Is there integration between Microsoft Outlook and Zoho Support? If so, can you point me to the related documentation? I'm trying to understand how that would work.
Unable to Send Ticket Reply as a Contact in Zoho Desk?
Hi Zoho Desk Team, I am trying to send a reply to a ticket on behalf of a contact using the Zoho Desk API. My goal is to have the contact's response reflected in the ticket conversation, but I am facing an issue where only the ticket author can comment.
MA 2.0 Email Footer
Good day, I recently went through the nightmare of upgrading from MA 1.0 to MA 2.0 and continue to experience more problems or missing features and settings. In this particular case, I am trying to find where and how to edit the Email Footer in MA 2.0.
How Can Integrate Zoho Recruit in a Laravel Website like Danvast.com?
What are the initial steps to integrate Zoho Recruit with a Laravel website? What API endpoints are necessary to begin the integration process? How can you set up Zoho Recruit API credentials in your Laravel environment? How do you manage API authentication
Not receiving New Ticket Emails
Hello! The company I work for uses the Zoho ticketing system, however, I've noticed I'm not receiving email notifications when new tickets are published. I have admin rights to see these tickets on Zoho Desk and respond to them, but am not receiving the
Is there a way to show contact emails in the Account?
I know I can see the emails I have sent and received on a Contact detail view, but I want to be able to see all the emails that have been sent and received between all an Accounts Contacts on the Account Detail view. That way when I see the Account detail
Unified WhatsApp Number Management in Zoho Desk and SalesIQ
Dear Zoho Desk Support Team, We are currently utilizing both Zoho Desk and Zoho SalesIQ for our customer support operations. While both platforms offer WhatsApp integration, we are facing challenges due to the requirement of separate WhatsApp numbers
Paste Screenshot in Ticket
We love Zoho Desk, but we miss the ability to paste screenshots directly into a ticket. I know that others have requested this functionality, but I thought it would be good to add it here as well.
Refreshing screen collapses Starred Views and Expands All Views
Just in the past few weeks I've noticed that when I refresh my screen, it now collapses my Starred Views section and Expands the All Views section. This is not how it used to work in the past. It is frustrating.
CRM email sync with 365 - app passwords
Hi We have synced users crm account with hosted 365 email accounts. 365 has MFA enforced across the tenant. Now encountering issues with 365 sync failing due to password errors after some time. Advised that will need to use app passwords from 365 in order
how to Add a TXT record in the DNS
hi everyone, i am using https://pradairways.weebly.com domain for practice purpose, now a Domain Verification - pradairways.weebly.com is required ,how to add txt reocrd in dns and complete the process. thanks in advanced
How can I reduce the size of the lightbox?
Hello - I want to reduce the size of the lightbox overlay function on my site. Currently it occupies the WHOLE screen when activated, which I'm not a huge fan of. Is there anyway I can reduce the size of the lightbox overlay? Say, it only takes up 75%
Items attribute questions
Many of my items have attributes, such as size and color. How can I add new fields to the "New Items" screen to capture that in my Purchase Orders, Items, and Sales Order pages? I only see these attribute fields when adding an Item Group. Also, on the
Update multi-select lookup via API? Or allow for import of multi-select Lookups?
When will the ability to update a multi-select lookup via API be available? Also when will we be able to import a record with multi-select lookups? I understand a linking module can help with this, but linking modules in our scenario would only be used
Would like to create a bounce-back for incoming emails
Hi all, I have a catch-all address, now from this I would like Zohomail to bounce back specific email addresses to the sender. Would like the server to send back an email from zoho servers stating that the intended addresse is no longer valid. while retaining
Cambiar nombre de usuario
Hola. Tengo una cuenta en zoho, por ejemplo Minombre @ midominio.es Y quiero cambiarlo a Miotronombre @ midominio.es Se puede cambiar??? Con la cuenta gratuita de zoho, cuantos nombres puedo tener en un dominio??? Gracias y buen dia
Error in connecting to WorkDrive
I'm trying to write a script to look in a specific WorkDrive folder and if there is a csv or xslx file, copy it to a different folder with a modified filename. That gave me the error: {"errors":[{"id":"F6016","title":"URL Rule is not configured"}]} So
Next Page