Get Records by ID from Salesforce in Zoho
The salesforce.sales.getRecordById() task is used to get records from any of the supported modules in your Salesforce account, by specifying the unique ID of the record. To connect Zoho Creator with Salesforce, create a new connection from the Setup - Connections page.
Supported Modules
- Account
- Campaign
- Case
- Contact
- Lead
- Product
- Solution
- Syntax
Syntax
<salesforceResponse> = salesforce.sales.getRecordById(
<salesforceConnectionName>,
<salesforceModuleName>,
<recordID>
);
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 |
<salesforceModuleName> | It refers to the module name in Salesforce from where the record is fetched |
<recordID> | It is the ID of the record in Salesforce that needs to be fetched |
Example - Fetch Records by ID
To fetch a record from the accounts module based on the recordID, 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.
salesforceResonse = salesforce.sales.getRecordById("Zoho", "Account", "00128000013bBMB");
Response Format
The response returned by Salesforce will be in the format given below:
{ "UpsellOpportunity__c":null,
"ParentId":null,
"Phone":null,
"TickerSymbol":null,
"SLAExpirationDate__c":null,
"Type":"Prospect",
"OwnerId":"00768000001h8THBBZ",
"LastModifiedDate":"2016-12-10T09:58:31.000+0000",
"ShippingState":null,
"AnnualRevenue":1000,
"BillingState":null,
"NumberofLocations__c":null,
"LastActivityDate":null,
"NumberOfEmployees":null,
"BillingPostalCode":null,
"SLASerialNumber__c":null,
"SystemModstamp":"2016-12-10T09:58:31.000+0000",
"ShippingCity":null,
"Description":null,
"BillingCountry":null,
"Site":null,
"ShippingCountry":null,
"LastModifiedById":"00768000001h8THBBZ",
"Website":null,
"ShippingStreet":null,
"AccountNumber":null,
"Fax":null,
"BillingStreet":null,
"SLA__c":null,
"Active__c":null,
"CustomerPriority__c":null,
"MasterRecordId":null,
"Name":"Inteygrate",
"BillingCity": "Hyderabad",
"Rating":null,
"CreatedById":"00768000001h8THBBZ",
"CreatedDate":"2016-12-10T09:58:31.000+0000",
"IsDeleted":false,
"Id":"00128000013bBMB",
"Ownership":null,
"attributes":"{
"type":"Account",
"url":"/services/data/v20.0/sobjects/Account/00128000013bBMB"
}",
"ShippingPostalCode":null,
"Sic":null,
"Industry":"Technology"
}
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 Script 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 Record by ID.
- 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.
- Insert the record ID of the record that needs to be fetched.
- 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 recordID. The response variable will contain the response returned by Salesforce.