Choose where you’d like to start

Fetch Records

Note: This task is applicable to all Zoho Services except Zoho Creator.

Overview

This task is used to fetch a list of records from a Zoho Cliq database, based on a given criteria.

This task is based on Zoho Cliq API - List Records.

Syntax

<variable> = zoho.cliq.getRecords(<database_name>, <query_map>, <connection>);
ParamsData typeDescription

<variable>

KEY-VALUE

specifies the variable which will hold the response returned by Zoho Cliq.

<database_name>

TEXT

specifies the unique name of the database from which the records will be fetched

<query_map>

KEY-VALUE

specifies the query parameters to fetch specific records. The applicable query params can be found here.

Click here to find the list of applicable operators that can be used to specify multiple values in criteria.

Note: You can provide an empty map in which case all the records will be fetched.

<connection>

TEXT

specifies the link name of the Zoho Cliq connection.

Note:

  • In view of stopping new authtoken generation, a Zoho OAuth connection with appropriate scopes is mandatory for new integration tasks (created after the deadline specified in the post) to work as expected. Existing integration tasks will continue to work with or without the connections parameter unless the authtoken is manually deleted from accounts.
  • Add relevant scopes as mentioned in Zoho Cliq API - List records
  • Refer to this post for the list of Zoho services that support the connections page.
  • Learn more about connections

Example1: Fetching records that satisfy static criteria

The following example fetches all the records from the database - availabilitydatabase that has a value - true in the column - availability.

 query_map=Map();
 query_map.put("criteria","availability==true");
 
 response_map=zoho.cliq.getRecords("availabilitydatabase",query_map, "cliq_connection");

where,

response_map
is the variable which will hold the KEY-VALUE response returned by Zoho Cliq.
"availabilitydatabase"
is the TEXT that represents the unique name of the database from which the records are fetched
query_map
is the KEY-VALUE variable that holds the query parameters
"criteria"
is the key of TEXT data type that specifies the search criteria
"availability==true"
is the value of TEXT data type that represents the search criteria
"cliq_connection"
is the TEXT that represents the name of the connection

Example2: Fetching records that satisfy dynamic criteria

Write the below script in the message handler of your Bot configuration to make it search and fetch records from the Zoho Cliq database - availabilitydatabase. The search condition is altered based on the user's response.

  • If the user sends YES to the Bot, the condition is set to availability==true. Thus, it fetches and displays all the records with value - true in the availability field.

  • Otherwise, the condition is availability==false. Thus, it fetches and displays all the records with value - false in the availability field.

 response  = Map();
 dynamic_value = false;
 
 if(message.containsIgnoreCase("YES"))
 {
 dynamic_value = true;
 }
 
 query = "availability=="+dynamic_value;
 text = zoho.cliq.getRecords("availabilitydatabase", {"criteria":query}, "cliq_connection");
 response.put("text",text);
 return response;

where,

message
is the object of TEXT data type that holds the most recent message sent in the Bot
text
is the TEXT variable that holds the response text to be sent by the Bot
"availabilitydatabase"
is the TEXT that represents the unique name of the database which needs to be searched
"criteria"
is the key of TEXT data type that specifies the search criteria
query
is the TEXT variable that holds the search condition
dynamic_value
is the BOOLEAN variable that holds the search value

The following is the response of the above script when the user sends YES.

Sample Response

Success Response

  • The success response returned is of the following format

     {
     "status":"SUCCESS",
     "url":"/api/v2/storages/availabilitydatabase/records",
     "list":
     [{"empid":"6","name":"John","availability":true,"id":"1775XXXX0002XXX431"},
     {"empid":"5","name":"Austin","availability":true,"id":"1775XXXX0002XXX469"},
     {"empid":"1","name":"Hanna","availability":true,"id":"1775XXXX0002XXX009"},
     {"empid":"2","name":"Kate","availability":true,"id":"1775XXXX0002XXX039"}]
     }

To fetch the ID of the newly created record, execute the following snippet:

<var1> =  <response_variable>.get("list");
for each <loop_variable> in <var1>
{
info <loop_variable>.get("id");
}

Failure Response

  • The failure response returned for an incorrect database name is of the following format

     {
     "status":"FAILURE",
     "message":"Uh-oh! Looks like availabilitydata does not exist.",
     "code":"platform_storage_database_not_found"
     }
  • The failure response returned for an incorrect or non-existent field name is of the following format

     {
     "status":"FAILURE",{
     "message":"The designation column does not exist.",
     "code":"platform_storage_column_not_exists"
     }
  • The failure response for a data type mismatch is of the following format

    {
     "status":"FAILURE",
     "message":"Invalid value given for field empid value Austin.",
     "code":"platform_storage_fields_invalid_value"
     }
  • The failure response for an invalid operator in criteria field is of the following format

     {
     "status":"FAILURE",
     "message":"Oops! Invalid operator specified for the criteria true",
     "code":"platform_storage_invalid_criteria_operator"
     }

Related Tasks

Get Started Now

Execute