Get Related Records from Zoho CRM

Get Related Records from Zoho CRM

Overview

Fetch dynamic records related to a particular module from Zoho CRM, using zoho.crm.getRelatedRecords() task in Zoho Creator. 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>]);

where,

Params DescriptionData type

<response> 

is the response returned by Zoho CRM.

LIST

<relation_name> 

is the API name of the related list.

Some default ones under Leads module are:

Notes

Calls

Events

Tasks

Campaigns

   - - -
STRING

<parent_module_name> 

API name of the Module to which the sub module belongs. For example "Notes" submodule belongs to "Leads" parent module.

Following is the list of supported modules

Leads

Potentials

Products

Contacts

Campaigns

Vendors

Accounts

Cases

Quotes

Sales_Orders

Purchase_Orders

Invoices

Note: Refer this for the instructions to get API names of the CRM modules and fields.

STRING

<record_id> 

ID of the parent module record whose related data needs to be fetched

BIGINT

<page>

  (optional)

is the starting index of the records that need to be fetched.

Default value: 1.

BIGINT

<per_page>

  (optional)

Used to get the list of records available per page.

Default value: 200.

BIGINT


Example 1: Fetch Notes from Leads module

In this example, we will fetch Notes from a Zoho CRM Lead record by specifying the record id. Assume we have a Zoho Creator Form with LeadID field(Zoho CRM Leads field type). To fetch Notes from the selected Lead, add the following script in the required workflow section:

notesinfo = zoho.crm.getRelatedRecords("Notes", "Leads", input.LeadID);

where,

notesinfo
is the response returned as map from Zoho CRM. Check sample response here. The returned repsonse contains the fetched records.
"Notes"
refers to the sub module, of string datatype, from where records need to be fetched.
"Leads"
refers to the parent module, of string datatype, to which the sub module belongs. In this example, "Notes" is the sub module which belongs to the Leads module. 
input.LeadID
is Zoho Creator field input which contains the id of the required Lead record.

Example 2: Fetch Contacts from Accounts module

In this example, we will fetch Contacts from a record in Zoho CRM Accounts module by specifying the record id. Assume we have a Zoho Creator Form with AccountID field(Zoho CRM Accounts field type). To fetch Contacts from the selected Account, add the following script in the required workflow section:

contactsinfo = zoho.crm.getRelatedRecords("Contacts", "Accounts", input.AccountID, 1, 10);

where,

contactinfo
is the response returned as map from Zoho CRM. Check sample response here. The returned repsonse contains the fetched records.
"Contacts"
refers to the sub module, of string datatype, from where records need to be fetched.
"Accounts"
refers to the parent module, of string datatype, to which the sub module belongs.
input.AccountID
is Zoho Creator field input which contains the id of the required Account record.
1 and 10
are the page and per_page values respectively.

Example 3: Fetch Events related to a Custom Module

In this example, we will fetch Events from a Custom Module record by specifying the record id. To achieve this add the following script in the required workflow section:

eventsinfo = zoho.crm.getRelatedRecords("Events", "Hotels", customModuleID, 1, 3);

where,

eventsinfo
is the response returned as list from Zoho CRM. Check sample response here. The returned repsonse contains the fetched records.
"Events"
refers to the sub module, of string datatype, from where records need to be fetched.
"Hotels"
is the API name of Zoho CRM Custom Module, of string datatype, to which the sub module belongs.
customModuleID
is the ID of the Custom Module record which contains the events to be fetched. This record ID can be retrieved by searching for the record using a unique criteria, and then extracting the record ID from the returned response. For more details, click here.
1 and 3
are page and per_page values respectively.

Response Format

Response returned is of the following format:

{  
   "Owner":{  
      "name":"Ben",
      "id":"2938383000000132011"
   },
   "Company":"Zillum",
   "Email":"bruce.wills@zillum.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":"2938383000000132011"
   },
   "Skype_ID":null,
   "$converted":false,
   "$process_flow":false,
   "Phone":"+1 678 904 1854",
   "Street":null,
   "Zip_Code":null,
   "id":"2938383000000399001",
   "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":"2938383000000132011"
   },
   "Fax":null,
   "Annual_Revenue":0,
   "Secondary_Email":null
}

Related Links

  • To fetch the string value to which the specified key is mapped, use get()
  • To get values from fetched records, use getJSON()
  • To convert the json string to list format, use toJSONList().

Share this post : FacebookTwitter

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

Write to us: support@zohocreator.com