Fetch Records from Salesforce
Table of Contents
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.
<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.
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();
SalesforceResponse = salesforce.sales.getRecords("CRM", "Account", "Name = 'Henry'",fieldList);
The response returned by Salesforce will be in the format given below:
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: '*'",