Get Related Records from Zoho CRM

Get Related Records from Zoho CRM

Overview

Zoho Creator and Zoho CRM have been integrated for efficient usability purposes. We have developed tasks in Zoho Creator to perform automatic actions in Zoho CRM, which would otherwise require manual execution. For example, you can fetch dynamic records, related to a particular module, from Zoho CRM and have them populated in Zoho Creator Form fields for further actions. 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. This can be achieved using zoho.crm.getRelatedRecords() task in Zoho Creator.

Use Case Scenario

Let's say we have a Zoho Creator form used by Sales Managers to view notes attached to each Lead. In this case, the getRelatedRecords() task can be executed to fetch and display notes based on the selected Lead. Further details on how to execute this task are explained below.

Syntax

<response>=zoho.crm.getRelatedRecords(<relation_name>, <parent_module_name>, <record_id>, [<page>],[<per_page>], <connections>);

where,

Params Description

<response> 

is the response returned as LIST by Zoho CRM.

<relation_name> 

is the API name of the related list. Sone default ones under Leads module are

Notes

Calls

Events

Tasks

Campaigns

   - - -

<parent_module_name> 

API name of the Module, of STRING datatype, to which the sub module belongs. For example "Notes" may belong to a "Leads" parent module. Following is the list of supported modules.

Leads

Potentials

Products

Contacts

Campaigns

Vendors

Accounts

Cases

Quotes

Sales_Orders

Purchase_Orders

Invoices

<record_id> 

To get the list of records based on pages. It is of the NUMBER datatype. Default: 1.

<page>

  (optional)

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

<per_page>

  (optional)

Used to get the list of records available per page. It is of the NUMBER datatype. Default: 200.

<connections>

  (optional) 

Displays the connectors associated with the function. Datatype is STRING.


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
}

Limitation

CRM Tasks can be executed only in accounts which are under Flexible and Unlimited Plans. Accounts under Free Plan, kindly upgrade to use CRM tasks. For more details scroll down to Integration and Web Data on the pricing page.

Script Builder

You can also make use of Script builder to define the zoho.crm.getRelatedRecords() task. Navigate to your application’s Workflow, and drag and drop the Call Function under Deluge Tasks > Miscellaneous. Select Integration tasks and fill out necessary information.

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