Search records in Salesforce from Zoho
The salesforce.sales.searchRecords() task is used to search records in any of the supported modules of your Salesforce account, directly from 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
<salesforceResponse> = salesforce.sales.searchRecords(
<salesforceConnectionName>,
<selectQuery>
);
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. |
<salesforceConnectionName> | It refers to the connection name used to connect Zoho Creator with Salesforce |
<selectQuery> | It contains the details of the record that you want to search. It must be in the following format: SELECT |
Example
To search a record from the accounts module, based on the query, 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.
SalesforceResponse = salesforce.sales.searchRecords("Zoho","SELECT Name,Id FROM Account WHERE Industry='Technology'");
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"}}]"
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"
}
Using 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 Search 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.
- Insert the query to fetch record.
- 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 query. The response variable will contain the response returned by Salesforce.