Deluge Help

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(<module_name>, <parent_module_name>, <record_id>, [<from_index>],[<to_index>]);

where,

Params Description

<response> 

is the response returned as LIST by Zoho CRM.

<module_name> 

is the name of the CRM module, of STRING datatype, from where the records will be fetched. For example, "Notes" refers to the Notes module under the specified parent module. Following is the list of supported modules. Apart from these, there are other dynamic modules as well which depend on the selected parent module.

Notes

Quotes

Products

Tasks

Campaigns

Events

Calls

Emails    - - -

<parent_module_name> 

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> 

Id of the parent module record that needs to be fetched. It is of Number datatype.

<from_index>

  (optional)

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

<to_index>

  (optional)

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

Note:

  • If only one index is mentioned, it will be considered as fromIndex. In this case, 20 records will be fetched, starting from the specified Index.
  • If both the indexes are not mentioned, last added 20 records will be fetched.
  • At any given time, a maximum of 200 records can be fetched.
  • Index number starts with 1.

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 Form Actions block:

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 Form Actions block:

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

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 3
are the start and end indexes, of number datatype, of Contacts sub module 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 Form Actions block:

eventsinfo = zoho.crm.getRelatedRecords("Events", "CustomModule1", 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.
"CustomModule1"
is the label 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 the start and end indexes, of number datatype, of Contacts sub module respectively.

Note:

  • Custom Modules are by default named as CustomModuleX (where X is a number). Specify the same Custom Module name format in the syntax.

Response Format

Response returned is of the following format:

{  
    "Account Name":"Creator Help Doc",
    "Add to QuickBooks":"false",
    "ACCOUNTID":"1560679000000413019",
    "Created By":"Creator Support Test",
    "MODIFIEDBY":"1560679000000084003",
    "CONTACTID":"1560679000000413013",
    "Created Time":"2016-03-17 16:32:00",
    "Modified By":"Creator Support Test",
    "SMOWNERID":"1560679000000084003",
    "Contact Owner":"Creator Support Test",
    "Email Opt Out":"false",
    "SMCREATORID":"1560679000000084003",
    "Last Activity Time":"2016-03-22 15:33:05",
    "Last Name":"vds ds",
    "First Name":"zxcs",
    "Modified Time":"2016-03-22 15:33:05"
},
{  
    "Account Name":"Creator Help Doc",
    "Add to QuickBooks":"false",
    "ACCOUNTID":"1560679000000413019",
    "Created By":"Creator Support Test",
    "MODIFIEDBY":"1560679000000084003",
    "CONTACTID":"1560679000000383001",
    "Created Time":"2016-02-25 22:13:00",
    "Modified By":"Creator Support Test",
    "SMOWNERID":"1560679000000084003",
    "Mobile":"56789765432",
    "Contact Owner":"Creator Support Test",
    "SMCREATORID":"1560679000000084003",
    "Email Opt Out":"false",
    "Last Activity Time":"2016-03-22 15:33:42",
    "Last Name":"rtyu",
    "First Name":"ret",
    "Modified Time":"2016-03-22 15:33:42"
}
 

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