Creating a Record in Salesforce
Table of Contents
The salesforce.sales.create() task is used to add a record to any of the supported modules in your Salesforce account, directly from your Zoho Creator Application. For example, you can create Leads for sales, create Contacts of prospective sales, create Accounts or Campaigns for these sales 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 newly created record.
<salesforceConnectionName> referes 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.
<params> is the map variable that holds the key,value pairs. The map key is the label name in the format as specified in Salesforce API. The map value is the field value as submitted from a Zoho Creator application.
A sample script to add an account to the Salesforce accounts module is given below. You can execute this script from a Zoho Creator form by adding it to the required Form Actions block. For example, to add a record to the accounts module, based on the values submitted from a Zoho Creator form,
- Select the Form from your Dashboard page.
- Click on Settings - On Add - Actions on Success.
- Add the script to the editor area.
- Click on Save Script to save the script definition.
//Declare Map Variable to hold the account details
Details = map();
//Add the account details to the map variable
//creating the account in the Salesforce accounts module with connection name "Zoho"
salesforceResponse = salesforce.sales.create("Zoho", "Account", Details);
- You can add the script directly to the editor area by selecting Free-flow scripting link displayed on the top-right corner of the script builder ( or ) use the drag-and-drop functionality in Script Builder.
- In the above example, we have specified the param values directly within quotes. To fetch the param values from a Zoho Creator form, specify the field name used in the form. For example, if Billing_city is the Field Deluge name, the key value pair should be specified in the following format: ("Billingcity", Billing_city)
The response returned by Salesforce will be in the format given below:
If the execution fails due to incorrect parameter value,the response will be in the following format:
"message":"Cannot deserialize instance of currency from VALUE_STRING value thousand at [line:1, column:2]",
To add the script using the drag-n-drop functionality in Script Builder,
- Select the Form from your Dashboard page
- Click on Settings - On Add - Actions on Success
- 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 Create Record.
- 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 required Module name in Salesforce.
- Select the map variable that holds the key-value pairs for the create request (or) click on "New Map" to add key-value pairs for the create request.
- 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 record gets added to selected module in Salesforce. The response variable will contain the response returned by Salesforce.
- The key-value pairs displayed will differ based on the module selected.