Creator Help

Creating a Record in Salesforce

Table of Contents

 Overview

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. 

 Supported Modules

  • Lead
  • Contact
  • Account
  • Case
  • Solution
  • Product
  • Campaign

 Syntax

<salesforceResponse> = salesforce.sales.create(<salesforceConnectionName>, <salesforceModuleName>, <params>);

where, 
<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.

 Example - To create a record

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,

  1. Select the Form from your Dashboard page.
  2. Click on Settings - On Add - Actions on Success.
  3. Add the script to the editor area.
  4. 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
    Details.put("Name","John");
    Details.put("BillingCity","Chicago");
    Details.put("Type","Prospect");
    Details.put("Industry","Chemicals");

    //creating the account in the Salesforce accounts module with connection name "Zoho"
    salesforceResponse = salesforce.sales.create("Zoho", "Account", Details);

Note

  • 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)

Response Format

The response returned by Salesforce will be in the format given below:

{"id":"00190000010xPIuAAM","errors":"[]","success":true}

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]",
"errorCode":"JSON_PARSER_ERROR"
}

 Using Script Builder

To add the script using the drag-n-drop functionality in Script Builder,

  1. Select the Form from your Dashboard page
  2. Click on Settings - On Add - Actions on Success
  3. Click on Script Builder from the top-right corner of the page.
  4. Drag and drop the call function in the editor box. 
  5. Select Integration tasks
  6. Select Service as Salesforce
  7. Select Function as Create Record.
  8. 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.
  9. Select the required Module name in Salesforce.
  10. 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. 
  11. Specify the response variable that will hold the response returned by Salesforce.
  12. 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. 

Note

  • The key-value pairs displayed will differ based on the module selected.

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohocreator.com