Choose where you’d like to start

Fetch records from Salesforce

Overview

Fetch records from Salesforce using this task.

Note: This task is applicable only to Zoho Creator.

Syntax

<variable> = salesforce.sales.getRecords(<salesforce_connection>, <salesforce_module><criteria>, <selectColumns>);

where,

ParameterDescriptionData type

<variable> 

is the variable which will hold the response returned by Salesforce.

KEY-VALUE

<salesforce_connection> 

is the name of the Salesforce connection.

TEXT

<salesforce_module>

is the name of the module in Salesforce from where the records will be fetched.

Following are the names of applicable modules.

Lead

Account

Contact

Case
SolutionProduct   Campaign
TEXT

<criteria>

(optional)

Criteria based on which the records will be fetched.

The criteria must be in the format "<field name> = '<value>'". For example, "Name = 'Henry'"

KEY-VALUE

<selectcolumns>

(optional)

Field names whose values will be included in the fetched records.

LIST

Fetch records from Salesforce

The following snippet when executed fetches records based on the specified criteria from the "Account" module in Salesforce, containing values only for the specified fields. 

fieldList = List();
fieldList.add("Name");
fieldList.add("Id");
fieldList.add("Industry");


response = salesforce.sales.getRecords("Salesforce", "Account", "Name = 'Henry'", fieldList);

where,

ParameterDescription
"Salesforce"is the name of the Salesforce Connection
"Account"is the module in Salesforce, from where the records will be fetched
"Name = 'Henry'"is the criteria based on which the records will be fetched
"fieldList"is a list variable which holds the list of field names whose values must be returned in the response
responseis response returned as map by Salesforce

Sample Response

Following is a sample success response returned by Salesforce:

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

You can fetch the record IDs from the response using the following snippet:

var = <response_variable>.get("records");
for each var1 in var
{
info var1.get("Id");
}

The following is a sample failure response, due to incorrect query:

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

Related Links

Get Started Now

Execute