Choose where you’d like to start

Get Related Records from Zoho CRM

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,

ParamsData typeDescription

<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 creatingsearching 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:
  • Currently there is no extra parameter supported by the Zoho CRM - Get Related Records API. To ignore querying, provide an empty map.
    For example: {"":""}
  • The <page> and <per_page> params must be specified to be able to specify this param.  

<connection>

(optional)

TEXT

specifies the name of the connection.

Note:
  • This param is not employed in Zoho Creator and mandatory in Zoho Cliq.
  • The <page>, <per_page>, <query_value> params must be specified to be able to specify this param.

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
is the value which will hold the response returned by Zoho CRM. It represents the values fetched from the records against the API names of its respective fields.
"Notes"
is the TEXT that represents the API name of the submodule, from where records need to be fetched.
"Leads"
is the TEXT that represents the parent module to which the submodule belongs. In this example, "Notes" is the submodule which belongs to the Leads module.

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
is the value which will hold the response returned from Zoho CRM. It represents the values of the fetched records against the API names of its respective fields.
"Events"
is the TEXT that represents the API name of the submodule from where records need to be fetched.
"Hotels"
is the TEXT that represents the API name of Zoho CRM custom module, to which the submodule belongs.
23033XXXXXXXXXXXXXX
is the NUMBER that represents the ID of the custom module record which contains the events to be fetched.
1 and 3
are page and per_page values respectively.

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:

<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>; 
  }
 

Note: Refer to Zoho CRM API document - Related Records Data for possible error responses.

Related Links

Get Started Now

Execute