Get 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 records from Zoho CRM and have them populated in Zoho Creator Form fields for further actions. Records can be fetched from multiple supported modules of Zoho CRM at the same time. This can be achieved using zoho.crm.getRecords() task in Zoho Creator.

Use Case Scenario

Let's say we need to populate a Zoho Creator Form with the last names of certain customers, already stored in Zoho CRM's Contacts module. In this case, records can be fetched from the Contacts module and the Last Name parameter can be extracted to be populated in the Form field. Further details on how to execute this task are explained below.

Syntax

<response>=zoho.crm.getRecords(<module_name>, [<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. Following is the list of supported modules.

Leads

Potentials

Products

Contacts

Campaigns

Vendors

Accounts

Cases

Quotes

Sales Orders

Purchase Orders

Invoices

<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 Customer Names from Contacts

Let's assume we have a Zoho Creator Form with Customer Name field to store Customer names. Records can be fetched from Zoho CRM Contact's Module by adding the script shown below in the required Form Actions block:

contactslist=zoho.crm.getRecords("Contacts");

The Customer Name of each fetched Contact can then be extracted and populated within the Form field using the ui.add() task. This can be achieved by adding the following script in the required Form Actions block:

for each ContactRecord in contactslist{Customer_Name:ui.add(ContactRecord.get("Last Name"));}

where,

contactslist
is the response returned asmapby Zoho CRM. It holds the records fetched from Zoho CRM’s
Contacts module. Check sample response here.
"Contacts"
refers to the Contacts module, ofstringdatatype, in Zoho CRM.
ContactRecord
stands for each unique record fetched from Zoho CRM's Contacts module.
Customer_Name
is the Form field which gets populated with customers' Names.

Example 2: Fetch Invoices and their Products

Let's assume we have a Zoho Creator Form with the following fields:

  • Subject (Single Line field type)
  • Invoice Date (Date field type)
  • Invoice Number (Number field type)
  • Product Name (Single Line field type)
  • Quantity (Number field type)
  • Unit Price (Currency field type)

To fetch records from Invoices module add the following script in the required Form Actions block:

InvoiceList=zoho.crm.getRecords("Invoices");

where,

InvoiceList
is the response returned, ofmapdatatype, from Zoho CRM.
"Invoices"
refers to the Invoices module, ofstringdatatype, in Zoho CRM.

Once the records are fetched, they can be iterated to extract the field values from each record which can be then assigned to respective form fields. For more details on this example, click here.

Example 3: Fetch data from a Custom Module

Let's say we have an email field in a Zoho Creator Form. To fetch an email address value for it from a Zoho CRM Custom Module, you can first fetch all the records from the Custom Module. The fetched records can then be iterated, as explained in example 1, to extract the email value of each record. To fetch records from a Custom Module, add the following script in the required Form Actions block:

CustomList=zoho.crm.getRecords("CustomModule3");

where,

CustomList
is the response returned asmapby Zoho CRM. It holds the records fetched from Zoho
CRM’s Custom Module. Check sample response here.
"CustomModule3"
is the label name of Zoho CRM Custom Module, of string datatype, from where the records
need to be fetched.

Note: Custom Modules are, by default, named as CustomModuleX (where X is a number). Specify the same Custom Module name format in the syntax. The URL of Zoho CRM Custom Module can be used to retrieve the Custom Module label name.

Response Format

The response returned is of the following format:

{  
         "Invoice Owner":"Creator Support Test",
         "Subject":"USA Shipping Corp",
         "Invoice Date":"2016-03-17",
         "Account Name":"Creator Help Doc",
         "Tax":"0",
         "INVOICEID":"1560679000000414015",
         "Invoice Number":"1560679000000414017",
         "Grand Total":"77",
         "ACCOUNTID":"1560679000000413019",
         "Created By":"Creator Support Test",
         "product":"          [{Product Name=Books, Quantity=3.0, List Price=23.0, Unit Price=23.0, Total After Discount=69.0, Quantity in Stock=-3.0, Tax=0.0, Net Total=69.0, Discount=0.0, Product Id=1560679000000414001, Total=69.0}, {Product Name=Stationary Items, Quantity=4.0, List Price=2.0, Unit Price=2.0, Total After Discount=8.0, Quantity in Stock=-4.0, Tax=0.0, Net Total=8.0, Discount=0.0, Product Id=1560679000000414009, Total=8.0}]",
         "MODIFIEDBY":"1560679000000084003",
         "Status":"Created",
         "Created Time":"2016-03-17 17:41:57",
         "Modified By":"Creator Support Test",
         "SMOWNERID":"1560679000000084003",
         "Discount":"0",
         "SMCREATORID":"1560679000000084003",
         "Sub Total":"77",
         "Adjustment":"0",
         "Modified Time":"2016-03-17 17:41:57"
}

Limitation

CRM Tasks can be executed only in accounts which are under Flexible and Unlimited Plans. If you are under the 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 the Script Builder to define the zoho.crm.getRecords() 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().