Get Related Records from Zoho CRM
Table of Contents
Description
This task is used to fetch records from a submodule(related list) related to a record in a parent module in Zoho CRM. For instance, Notes attached to a particular Lead or Contacts linked to a particular account can be fetched using the ID of the parent module record.
Syntax
<response> = zoho.crm.getRelatedRecords(<relation_name>, <parent_module_name>, <record_id>, <page>, <per_page>, <query_value>, <connection>);
where,
Params | Data type | Description |
<response> | KEY-VALUE | specifies the response returned by Zoho CRM. It represents the values fetched from the records against the API names of its respective fields. |
<relation_name> | TEXT | specifies the API name of the submodule or the related list. |
<parent_module_name> | TEXT | specifies the API name of the module to which the submodule belongs. For example, "Notes" submodule belongs to "Leads" parent module. |
<record_id> | NUMBER | specifies the ID of the parent module record whose related data needs to be fetched. Learn how to fetch the ID of a record after creating, searching or fetching it. |
<page> (optional) | NUMBER | refers to the starting index of the records that need to be fetched Default value: 1 |
<per_page> (optional) | NUMBER | specifies the number of records that need to be fetched per page Default value: 200 |
<query_value> (optional) | KEY-VALUE | holds all the other parameters specified in the Zoho CRM API. Note:
|
<connection> (optional) | TEXT | specifies the name of the connection. Note:
|
Example 1
The following script fetches all the Notes associated to the Lead with ID - 23033XXXXXXXXXXXXXX in Zoho CRM.
notesinfo = zoho.crm.getRelatedRecords("Notes", "Leads", 23033XXXXXXXXXXXXXX​);
where,
notesinfo
"Notes"
"Leads"
Example 2
The following script fetches all the records from the Events submodule associated with the custom module - Hotels
eventsinfo = zoho.crm.getRelatedRecords("Events", "Hotels", 23033XXXXXXXXXXXXXX, 1, 3);
where,
eventsinfo
"Events"
"Hotels"
23033XXXXXXXXXXXXXX
1 and 3
Response Format
The following is a sample response returned when related records are fetched:
{
"Owner":{
"name":"Ben",
"id":"23033XXXXXXXXXXXXXX"
},
"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":"23033XXXXXXXXXXXXXX"
},
"Skype_ID":null,
"$converted":false,
"$process_flow":false,
"Phone":"+1 678 XXX XXXX",
"Street":null,
"Zip_Code":null,
"id":"23033XXXXXXXXXXXXXX",
"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":"23033XXXXXXXXXXXXXX"
},
"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>;
}
Note: Refer to Zoho CRM API document - Related Records Data for possible error responses.