Get Records from Zoho CRM
Table of Contents
Description
This task is used to fetch records from the specified Zoho CRM module.
Syntax
<variable> = zoho.crm.getRecords(<module_name>, <page>, <per_page>, <query_value>, <connection>);
where,
Params | Data type | Description |
<variable> | KEY-VALUE | is the response returned by Zoho CRM. It represents the values fetched records against the API names of its respective fields. |
<module_name> | TEXT | is the API name of the Zoho CRM module from where the records will be fetched. |
<page> (optional) | NUMBER | is used to get the list of records based on pages. Default value: 1 |
<per_page> (optional) | NUMBER | is used to get the list of records available per page. Default value: 200 |
<query_value> (optional) | KEY-VALUE | is used to hold all the other parameters specified in the Zoho CRM API. Note:
|
<connection> (optional) | TEXT | The link name of the connection. Note:
|
Example 1: Fetch records from Contacts module
The following script fetches the first 10 records from the Zoho CRM Contacts module an sorts the fetched records in ascending order based on the field - First_Name.
query_map = Map(); query_map.put("sort_order", "asc"); query_map.put("sort_by", "First_Name"); response = zoho.crm.getRecords("Contacts", 1, 10, query_map, "crm_oauth_connection");
where:
response
"Contacts"
1
10
query_map
"sort_order" "sort_by"
"crm_oauth_connection"
Example 2: Fetch data from a Custom Module
The following script fetches all the records from Zoho CRM custom module - Hotels
query_map = Map(); response = zoho.crm.getRecords("Hotels", 1, 200, query_map, "crm_oauth_connection");
where:
response
CRM’s Custom Module.
"Hotels"
Response Format
The success response returned when a Lead is fetched from Leads module is of the following format.
"Owner":{
"name":"Ben",
"id":"29383XXXXXXXXXXXXXX"
},
"Company":"Zylker",
"Email":"bruce.wills@zylker.com",
"Description":null,
"Discount":null,
"$currency_symbol":"$",
"Total_Amount":null,
"Rating":null,
"Website":null,
"Twitter":null,
"Salutation":null,
"Last_Activity_Time":null,
"First_Name":null,
"Full_Name":"Wills",
"Lead_Status":null,
"Industry":null,
"Modified_By":{
"name":"Ben",
"id":"29383XXXXXXXXXXXXXX"
},
"Skype_ID":null,
"$converted":false,
"$process_flow":false,
"Phone":"+1 678 XXX XXXX",
"Street":null,
"Zip_Code":null,
"id":"29383XXXXXXXXXXXXXX",
"Email_Opt_Out":false,
"$approved":true,
"Designation":null,
"$approval":{
"delegate":false,
"approve":false,
"reject":false,
"resubmit":false
},
"Modified_Time":"2018-03-28T11:34:40+05:30",
"Created_Time":"2018-03-28T11:34:40+05:30",
"$converted_detail":{
},
"$followed":false,
"$editable":true,
"City":null,
"No_of_Employees":0,
"Mobile":null,
"Last_Name":"Wills",
"State":null,
"Total":0,
"Lead_Source":null,
"Country":"United States",
"Tag":[
],
"Created_By":{
"name":"Ben",
"id":"29383XXXXXXXXXXXXXX"
},
"Fax":null,
"Annual_Revenue":0,
"Secondary_Email":null
}
To get the list of record IDs from the response, execute the following snippet:
<variable> = <response_variable>.toJsonList();
for each <loop_variable> in <variable>
{
<variable1> = <loop_variable>.getJson("id");
<list_variable>.add(variable1);
info <list_variable>;
}