Creator Help

Fetching Records From Zoho CRM

You can fetch records from a CRM module and update it in Zoho Creator form using the getRecords() task.

Deluge code for fetching all records from CRM Module

Syntax

<list-variable> = zoho.crm.getRecords("<ModuleName>",<fromIndex>,<toIndex>);

where, <ModuleName> refers to the module name in crm from which the records are fetched.

Return type: The zoho.crm.getRecords() task returns the value as a "list"

Example

  1. In this example, we will fetch the Zoho CRM Leads from the Leads module, Zoho CRM Item names from the Products module and update it in the Creator form.
  2. Select the Zoho Creator Form and select More Actions -> Script on add -> Actions on load from the form header, to add the required script in the "on load" block of the form.
  3. This will display the Script editor with the on add -> on load block selected. In the script editor area, write the script to get the records from CRM and populate it in Zoho Creator form fields, as shown in the screen-shot given below:
           
  4. The Deluge code added to the on add -> on loadblocks given below for reference:

    leadslist = zoho.crm.getRecords("Leads");
    for each leadDet in leadslist
    {
    Customer_Name:ui.add(leadDet.get("Last Name"));
    }
    productsList = zoho.crm.getRecords("Products");
    for each productDet in productsList
    {
    Item_Name:ui.add(productDet.get("Product Name"));
    }

  5. The following Deluge code is added to the Field Actions -> Item Name -> On user input block, to calculate the item rate for the selected item. Click Save Scriptto save the script.

    input.Item_Rate = 0.0;
    productsList = zoho.crm.getRecords("Products");
    for each productDet in productsList
    {
    productName = productDet.get("Product Name");
    if (productName.equalsIgnoreCase(input.Item_Name))
    {
    input.Item_Rate = productDet.get("Unit Price");
    }
    }

  6. The following is the Zoho Creator form that has "Customer Name" lookup field fetched from ZohoCRM Leads module, "Item Name" lookup field fetched from ZohoCRM Products module, and the " Item Rate" field, an attribute of Products module in CRM.

Using Script Buider

You can define the getRecords() task using Script Builder by following the steps given below:

  1. Drag and drag the Call function to the builder area and select Integration Tasks.
  2. Select the Service as Zoho CRM and the function as getrecords.
  3. Select the required CRM Module to which the record will be added.
  4. Specify the From/To index. The default value of From index is 1 and To index is 20. The maximum value of To index is 200.
  5. Specify the CRM Response Variable and click Done to add the task to the script builder.
  6. Click Save Script to add the script.

Related Links

http://www.zoho.com/crm/help/api/getrecords.html

Top