Get Records from Zoho CRM

Get Records from Zoho CRM

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,

ParamsData typeDescription

<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:
  • The keys and values of this param should be provided according to the Zoho CRM API.
  • The <page> and <per_page> params must be specified to be able to specify this param.  
  • To ignore querying using this param, specify an empty map.

<connection>

(optional)

TEXT

The link name of the connection.

Note:

  • In view of stopping new authtoken generation, a Zoho OAuth connection with appropriate scopes is mandatory in order 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 until you manually delete the authtoken from accounts.
  • Add relevant scopes mentioned in Zoho CRM - get records API while creating the connection.
  • Refer to this post for the list of Zoho services that support the connections page.
  • Learn more about connections

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
is the variable which will hold the response returned by Zoho CRM. It holds the records fetched from Zoho CRM’s Contacts module.
"Contacts"
is the TEXT that represents the API name of the Zoho CRM module from which the records will be fetched
1
is the NUMBER that represents the index of the first record that will be fetched
10
is the NUMBER that represents the number of records that will be fetched
query_map
is the KEY-VALUE variable that holds the query parameters
"sort_order" 
"sort_by"
are the TEXT keys as specified in the Zoho CRM API that are required to sort the fetched records.
"crm_oauth_connection"
is the TEXT that represents the link name of the 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
is the variable which will hold the response returned by Zoho CRM. It holds the records fetched from Zoho
CRM’s Custom Module.
"Hotels"
is the TEXT that represents the API name of the Zoho CRM's custom module from which the records are to be fetched.

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:

<list_variable> = list();
<variable> = <response_variable>.toJsonList();
for each <loop_variable> in <variable>
{
<variable1> = <loop_variable>.getJson("id");
<list_variable>.add(variable1);
info <list_variable>;
}

Related Links

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com