Fetch Records from Salesforce in Zoho
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. To connect Zoho Creator with Salesforce, add a new connection from the Setup - Connections page.
Supported Modules
- Account
- Campaign
- Case
- Contact
- Lead
- Product
- Solution
- Syntax
Syntax
<salesforceResponse> = salesforce.sales.getRecords(
<salesforceConnectionName>,
<salesforceModuleName>,
<criteria>,
<ColumnsToBeSelected>
);
Below is the description of each parameter
Param Name | Description |
---|---|
<salesforceResponse> | It is the map variable returned as response. It contains the details of the record that needs to be fetched. |
<salesforceModuleName> | It refers to the module name in Salesforce where the record is created |
<criteria> | It is the optional parameter based on which the records wll be fetched. The criteria must be in the format |
<columnsToBeSelected> | It is the optional parameter which specifies the name of the attributes to be selected. |
Example - Fetch Records
To fetch a record from the accounts module, follow the below steps:
- Select the Form from your Dashboard page.
- Go to the required Form Actions block.
- Add the below script to the editor area.
- Click on Save Script to save the script definition.
"Accounts" module
SalesforceResponse = salesforce.sales.getRecords("CRM", "Account");
SalesforceResponse = salesforce.sales.getRecords("CRM", "Account","Name = 'Inteygrate'");
fieldList = List();
fieldList.add("Name");
fieldList.add("Id");
fieldList.add("Industry");
SalesforceResponse = salesforce.sales.getRecords("CRM", "Account", "Name = 'Inteygrate'",fieldList);
Response Format
The response returned by Salesforce will be in the format given below:
{
"done":true,
"records":"[{\"Name\":\"Inteygrate\",\"Id\":\"00128000013bBMB\",\"attributes\":
{\"type\":\"Account\",\"url\":\"/services/data/v20.0/sobjects/Account/00128000013bBMB\"},\"Industry\":\"Technology\"}]",
"totalSize":1
}
If the execution fails due to Malformed Query,the response will be in the following format:
{
"message":"\nSELECT * FROM Account where Name='Inteygrate'\n ^\nERROR at Row:1:Column:7\nunexpected token: '*'",
"errorCode":"MALFORMED_QUERY"
}
##Script Builder
To add the script using the drag-n-drop functionality in Script Builder,
- Select the Form from your Dashboard page.
- Go to the required Form Actions block.
- Click on Scrip Builder from the top-right corner of the page.
- Drag and drop the call function in the editor box.
- Select Integration tasks.
- Select Service as Salesforce.
- Select Function as Get Records.
- Select the Connection Name to connect with Salesforce. Click on +Create to create a new connection or create a new connection from the Setup - Connections page.
- Select the module name in Salesforce, from where you need to fetch the record.
- Specify the criteria based on which the records will be fetched. This is an optional parameter.
- Specify the columns to be fetched. This is an optional parameter.
- Specify the response variable that will hold the response returned by Salesforce.
- Click on Done to insert the call function task.
Upon submission of the form, the specific record gets fetched from Salesforce based on the given module name and criteria. The response variable will contain the response returned by Salesforce