Deluge Help

Fetch Records from Salesforce

Table of Contents

 Overview

The salesforce.sales.getRecords() task is used to fetch records from any of the supported modules in your Salesforce account, to your Zoho Creator Application. For example, you can fetch records from Salesforce modules like Leads, Contacts, Accounts etc. To connect Zoho Creator with Salesforce, add a new connection from the Setup - Connections page.

 Supported Modules

  • Lead
  • Contact
  • Account
  • Case
  • Solution
  • Product
  • Campaign

 Syntax

<salesforceResponse> = salesforce.sales.getRecords(<salesforceConnectionName>, <salesforceModuleName>, <criteria>, <ColumnsToBeSelected>);

where,
<salesforceResponse> is the map variable returned as response. It contains the details of the record that needs to be fetched.
<salesforceConnectionName> refers to the connection name used to connect Zoho Creator with Salesforce. Create a new connection from the Setup - Connections page.
<salesforceModuleName> refers to the module name in Salesforce where the record is created.
<criteria> is the optional parameter based on which the records wll be fetched. The criteria must be in the format <attribute name> = <value>. For example, "Name = 'Henry'"
<columnsToBeSelected> is the optional parameter which specifies the name of the attributes to be selected.

 Example

A sample script to fetch a record from the Salesforce accounts module is given below. You can execute this script from a Zoho Creator form by adding it to the required workflow section​.

//returns a list of records from the Salesforce "Accounts" module
SalesforceResponse = salesforce.sales.getRecords("CRM", "Account");

//returns a list of records with Name = "Henry"
SalesforceResponse = salesforce.sales.getRecords("CRM", "Account","Name = 'Henry'");

//returns the Name, ID and Industry of the records from the Salesforce "Accounts" module with Name ="Henry"
fieldList = List();
fieldList.add("Name");
fieldList.add("Id");
fieldList.add("Industry");
SalesforceResponse = salesforce.sales.getRecords("CRM", "Account", "Name = 'Henry'",fieldList);

Response Format

The response returned by Salesforce will be in the format given below:

{
"done":true,
"records":"[{\"Name\":\"Henry\",\"Id\":\"00190000010bZ88AAE\",\"attributes\":
{\"type\":\"Account\",\"url\":\"/services/data/v20.0/sobjects/Account/00190000010bZ88AAE\"},\"Industry\":\"Chemicals\"}]",
"totalSize":1
}

If the execution fails due to Malformed Query,the response will be in the following format:

{
"message":"\nSELECT * FROM Account where Name='John'\n ^\nERROR at Row:1:Column:7\nunexpected token: '*'",
"errorCode":"MALFORMED_QUERY"
}

Share this post : FacebookTwitter

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

Write to us: support@zohocreator.com