Types of Queries

Zoho CRM Queries support multiple query types based on the data source you select during query configuration. The query type determines how the system retrieves and processes data.
You can run queries on Zoho CRM data as well as external systems accessible through REST APIs. The system determines the query type based on the source you associate with the query.

Source and Query Type Relationship

A source defines the origin of data for a query. The system uses the selected source to decide how to execute the query.

  • When you select CRM module as the source, the system retrieves records from that module.
  • When you select COQL as the source, the system executes a SQL-like query on CRM data.
  • When you select a REST API source, the system sends an HTTP request to an external service and retrieves data from it.
  • When you select a database or cloud data source, the system executes queries directly on the connected data store.

Query Types

CRM - Modules

Use this query type to retrieve records from a specific Zoho CRM module. This query

  • Retrieves data from a single module
  • Supports field selection and filtering
  • Returns structured CRM records.

Examples

  • Display module records in Canvas or Kiosk
  • Fetch related records within CRM

Follow these steps to create a CRM - Module type query.

  1. Go to Setup -> Developer Hub -> Queries. The Queries window opens.
  2. Click Create Query.
  3. In the "Create Query" pop up, enter the following details:
    • Enter Query Name and API Name. Click Next.

    • Under Configuration, the default query type will be Zoho CRM Module. If you want to change the type, click Change.
    • For Module type query, choose the module in CRM for which you want to create the query. You can also create queries for Subforms.
    • If your module has lookup fields, you can also include them in your query. Choose the required lookups in the Related Module drop down. Note that you can choose a maximum of two fields in this drop down.
    • Select the required fields for your query from the Fields drop down. Note that you can choose a maximum of 50 fields here.

  4. Under Criteria, you can choose to get all records, or filter the response by the record ID or apply criteria.
    • None - This option does not apply any criteria.
    • Criteria - You can apply criteria over different fields for which you are creating the query. Criteria supports various comparators and you can also group the conditions using AND or OR operators. You can also choose to give the value for the criterion or choose a dynamic value. Dynamic value means that the value will be taken for this field when the query is used at some place. In this example, we are assigning a variable to get the ID of the contact record that is associated with the deal that meets the criteria.

    • Record ID - Choose this option if you want to apply the query to a specific record. You can assign a variable to this field and pass the record ID during execution.
  5. Under Serializer, click Add Serializer to modify the response through JavaScript. You can then use this modified response for further processing. The following image shows an example of a serialized response. Click Save.

  6. You can also sort the response based on a field either in the ascending or descending order. Under Advanced, choose the field to be sorted on in the Order by drop down and the order in which it has to be sorted.
  7. Click Execute Query. If your query has a dynamic value in criteria, you will get a pop up asking for its value. Specify the value and click Next. You will see the response of the query you created.
  8. After the query executes, you can see the Schema at the bottom of the screen. Path indicates the JSON path in the response that the field is available in, CRM Field Type indicates it's field type in CRM such as long int, int, and the Label indicates the label/name of the field. You can edit these values based on what you need in the query's response.

  9. Click Save to save your query.

COQL

Use COQL type (CRM Object Query Language) to run SQL-like queries on CRM data using the Query API.
Refer to Get Records through a COQL query for details on constructing this type of query, the various supported field types, their operators etc.
This query

  • Lets you write SELECT queries with conditions
  • Allows you to query across related modules using lookup fields
  • Supports sorting, grouping, and aggregation.

Examples

  • Retrieve filtered datasets
  • Query related modules
  • Aggregate CRM data

Follow these steps to create a CRM - COQL type query.

  1. Go to Setup -> Developer Hub -> Queries. The Queries window opens.
  2. Click Create Query.
  3. In the "Create Query" window, under Configuration, enter the following details:
    • By default, the type will be Zoho CRM Module. Click Change to choose another type of query. Select Zoho CRM COQL.
    • Click Done.
    • Enter the COQL query. You can refer to the Get Records through a COQL query for details on constructing a query. Click Next.

  4. Click Add Serializer if you want to serialize the output of the query.
  5. Click Execute Query to execute and see the response.
  6. At the bottom of the screen, you can see the Schema. Path indicates the JSON path in the response that the field is available in, CRM Field Type indicates it's field type in CRM such as long int, int, and Label indicates the label/name of the field. You can edit these values based on what you need in the query's response.

REST API

Use this query type to fetch data from external systems through REST APIs. To use this query type, you must configure a REST API source
This query

  • Sends HTTP requests to external endpoints
  • Lets you configure URL paths, query parameters, and headers
  • Uses connections to handle authentication
  • Lets you map the response to a defined schema.

Examples

  • Fetch data from third-party services
  • Integrate data from other Zoho applications
  • Use external data inside CRM interfaces such as Canvas or Kiosk.

Follow these steps to create a query to use data from an external service.

  1. Click Create Query.
  2. By default, the type will be Zoho CRM Module. Click Change to choose another type of query. Select REST API.
  3. Select the source of your query from Source.
  4. Enter the endpoint of the external source to fetch data from and any parameters and headers for the request.
  5. If you want to serialize the response, click Add Serializer.
  6. Click Execute Query to see the response.
  7. Under Schema, you can see the Path, CRM Field Type, and the Label. Path indicates the JSON path in the response that the field is available in, CRM field type indicates it's field type in CRM such as long int, int, and the label indicates the label/name of the field. You can edit these values based on what you need in the query's response.

  8. Click Save to save your query.

External Databases

Use this query type to retrieve data from external relational databases. To use this query type, configure a database source.
This query

  • Connects to relational databases such as MySQL, MicrosoftSQL, or PostgreSQL
  • Executes structured queries directly on the database
  • Retrieves tabular data with defined schema

Examples

  • Fetch operational data stored outside CRM
  • Integrate backend systems with CRM interfaces
  • Query large structured datasets from external databases.

Follow these steps to create a database source.

  1. Navigate to Setup > Developer Hub > Queries.
  2. Click Sources.
  3. Click Create Source.
  4. Choose from one of the available database sources. The following image shows the MySQL database.

  5. Provide the following details such as Name, Host, User Name, Password, Database Name, and Schema.
  6. Refer to Advanced Configuration section for details on SSL, time zone, and read-only properties of custom sources.
  7. Click Validate and Save. After validation succeeds, Zoho CRM saves the source and makes it available for queries.

Cloud Database Platforms

Use this query type to retrieve data from cloud-hosted databases. To use this query type, create a Cloud Database source with provider-specific configuration.
This query

  • Connects to cloud-managed databases such as Microsoft Azure, Amazon RDS, Google Cloud Platform
  • Retrieves structured data from cloud-hosted systems.

Follow these steps to create a database source.

  1. Navigate to Setup > Developer Hub > Queries.
  2. Click Sources.
  3. Click Create Source.
  4. Choose from one of the available database sources. The following image shows the Microsoft Azure database.

  5. Provide the following details such as Name, Host, User Name, Password, Database Name, and Schema.
  6. Under Advanced configuration, you can configure the following.
    • Time Zone - Select the time zone for the database session. The system uses this setting to interpret and return time-based data correctly.
    • Connection timeout - Specify the maximum time (in seconds) the system must wait to establish a connection before timing out.
    • Use SSL - Enable this option to establish a secure connection between Zoho CRM and the database.
    • Read Only - Enable this option to restrict the connection to read operations. The system will not allow write operations when you enable this setting.
  7. Click Validate and Save. After validation succeeds, Zoho CRM saves the source and makes it available for queries.

Advanced Configuration for Database and Cloud Database Platforms

Use the Advanced configuration section to control how Zoho CRM connects to and interacts with database and cloud data sources. These settings affect security, time handling, and data access behavior.

Use SSL

Enable this option to establish a secure connection between Zoho CRM and the data source.
When you enable SSL:

  • The system encrypts the connection.
  • The system validates the server certificate and hostname before establishing the connection.

Note

  • Hostname verification works only when you use DNS names. If you use an IP address, the system establishes an encrypted connection but does not perform hostname verification.
  • If you add a host to Trusted Domains, the system bypasses hostname and certificate validation. Add only trusted and secure hosts. You cannot modify this setting after you successfully create the source.

Time Zone

Use this option to specify the time zone of the data source. The system uses this setting to correctly handle date and time values during read and write operations.

  • When reading data, the system converts date and time values from the source time zone to the time zone of the user retrieving the data.
  • When writing data, the system processes date and time values as follows.
    • If the value includes a time zone (ISO 8601 format), the system uses it as provided.
    • If the value does not include a time zone, the system assumes the user’s time zone and converts it to the source time zone.

Note

  • If the source field type supports time zone (for example, timestamp with time zone), the system stores and retrieves values without conversion.
  • The system does not apply time zone conversions to date-only values.

Connection Timeout

Use this option to define how long the system waits (in seconds) to establish a connection before timing out.

Read only

Enable this option to restrict the source to read operations. When you enable this option,

  • The system allows only retrieval operations such as SELECT queries
  • The system blocks write operations such as INSERT, UPDATE, and DELETE

You can modify this setting after you create the source.

Note

Users with Developer permissions in Zoho CRM can access all configured sources, including SQL (database and cloud) sources within the organization.
If you configure a source using credentials with elevated privileges (for example, a superuser account) or connect to a sensitive database, Developer users may be able to access restricted data through queries or other features that use these sources.
To prevent unintended data exposure, use credentials with the minimum required permissions and restrict access to sensitive data at the database level.

See Also