Requirement
Enhance customer management by integrating the Contacts module of Salesforce with Zoho Creator.
Use Case
Consider an organization that manufactures electronic products and utilizes Zoho Creator Order Management Application for sales and relies on
Salesforce for CRM. They use Creator for order placement and product inventory management, and Salesforce to implement customer retargeting and analyze purchasing trends. When a customer wants to buy a product, the customer will approach the sales person and the sales person will place the order in the
New Order form of the Order Management Creator application. There are two types of customers: new customers and existing customers.
When a new customer approaches to place an order, the Salesforce integration form will be used to facilitate the collection of essential customer details. This data will be transferred automatically to the Salesforce Contacts module, after which the order will be placed.
For existing customers, the system will seamlessly cross-reference the entered customer's email with the records stored in the Salesforce Contacts module. Consequently, pertinent fields associated with the customer, such as name, phone number, address in the New order form, will be auto-populated by extracting the relevant data from the Salesforce to place the order.
Prerequisites
A
Salesforce account to store and retrieve customer details from its Contacts module.
Steps to Follow
![](https://static.zohocdn.com/zoho-desk-editor/static/images/info.png)
Info:
Datasource and
connection are necessary for creating an integration form or integration field. If you already have them created, you can simply select the required datasource or connection. However, in the below steps, you will be creating a new datasource and connection while creating an integration form.
- Create an integration form to add the customer details to Salesforce, with the name Customer Details, and click Add Datasource.
![](https://help.zoho.com/galleryDocuments/edbsn66f98e0421a0b0bb007c87bdcac18dc7237edfbf098c708d83fb010a688fa74525e23850b63c456a2c7ae089854c9dd5?inline=true)
- Click Add Connection in the pop-up to create a Salesforce connection.
![](https://help.zoho.com/galleryDocuments/edbsn372ff05d50182a27e0a76ff7fb242f2be0a0ec81d23d63d94b636851e2fa34b10b469744fb8e84d12ae171191862c24c?inline=true)
- Provide the details shown below and click Create and Authorize.
![](https://help.zoho.com/galleryDocuments/edbsn3a66a911720a3329c149ff915f2bcbe701aa250ba290ca69fe0c738dba4516f177db25af5b950b1b2240294c04faa048?inline=true)
You will be routed to the Add Datasource page. - Fill in the details as shown in the below image, then click Create.
![](https://help.zoho.com/galleryDocuments/edbsn962ff6da1d854597809e066f06580cd34f3bf942226314cbfc5ae224ba04040a6a22cea1ef778c27d8134d8ca42e08cd?inline=true)
Upon successful creation, the form builder of your new integrated Customer Details Salesforce form will open. - Drag and drop the following Salesforce's contact modules fields from the left pane of the form builder into your form. You can also add other fields from your Salesforce Contacts module depending on your preference.
This use case can be demonstrated using just the above-mentioned fields. You can include as many fields as required.
Form | Form Link Name | Field Link Name | Field Name |
Customer Details | Customer_Details | firstname | First Name |
lastname | Last Name |
email | Email |
phone | Phone |
mailingstreet | Mailing Street |
mailingcity | Mailing City |
mailingcountry | Mailing Country |
mailingpostalcode | Mailing Zip/Postal Code |
- Create a form with the following details to collect orders from the customer.
Form | Form Link Name | Field Type | Field Name | Field Link Name |
New Order | New_Order | Integration | Email | Email |
Decision Box | New Customer | New_Customer |
Name | Customer Name | Customer_Name |
Phone | Mobile | Mobile |
Address | Address | Address |
SubForm | Orders List | Orders_List |
Currency | Grand Total | Grand_Total |
Note: While creating an integration field in the New Orders form, select the details as shown below. You can also select the same datasource which is selected while creating the integration form.- Create a workflow to execute on user input of the New Customer field in the New Order form with the details shown below. This workflow will open the Customer Details integration form in pop-up, if the New Customer decision box is selected.
![](https://help.zoho.com/galleryDocuments/edbsn2cba3c749a5d278e401b085c67f50f0f8ebc97c82caea0666a091bab9beeb16981b6b4dc7c225a57b98f69e764620190?inline=true)
- Add the folowing code in the Deluge editor.
- //When the New Customer decision box is selected, the OpenUrl task opens the Customer Details integration form in a pop-up.
- if(New_Customer == true)
- {
- openUrl("#Form:Customer_Details","popup window","height=700,width=550");
- }
- Create another workflow to execute on user input of Email field in the New Order form with the details shown below. This workflow will fetch the customer details form the Salesforce and auto populate data in the respective fields.
![](https://help.zoho.com/galleryDocuments/edbsn5fd010fd0c9522b0383571f3765f936d4b36921fc84d9abd625b098da505e035275e54f4a32797b891d68ba0a4064996?inline=true)
- Add the followingcode in the Deluge editor.
// Create a list to add the required fields that needs to be fetched from the Salesforce contact module
- fieldList = List();
- fieldList.add("firstname");
- fieldList.add("lastname");
- fieldList.add("email");
- fieldList.add("phone");
- fieldList.add("mailingstreet");
- fieldList.add("mailingcity");
- fieldList.add("mailingstate");
- fieldList.add("mailingcountry");
- fieldList.add("mailingpostalcode");
- //Create a variable to store the response of the Salesforce - Get Records integration task which fetches the record from the Salesforce contacts module matching the email Id from the Email field.
- response = salesforce.sales.getRecords("Salesforce","contact","ID=" + "'" + input.Email + "'",fieldList);
- //If the Email field is not empty, populate the respective fields with the Salesforce - Get Records integration task response; otherwise, fill the respective fields with an empty string.
- if(Email.isEmpty() == false)
- {
- input.Name.first_name = response.getJSON("records").getJSON("FirstName");
- input.Name.last_name = response.getJSON("records").getJSON("LastName");
- input.Phone_Number = response.getJSON("records").getJSON("Phone");
- input.Address.address_line_1 = response.getJSON("records").getJSON("MailingStreet");
- input.Address.district_city = response.getJSON("records").getJSON("MailingCity");
- input.Address.state_province = response.getJSON("records").getJSON("MailingState");
- input.Address.country = response.getJSON("records").getJSON("MailingCountry");
- input.Address.postal_Code = response.getJSON("records").getJSON("MailingPostalCode");
- }
- else
- {
- input.Name.first_name = "";
- input.Name.last_name = "";
- input.Phone_Number = "";
- input.Address.address_line_1 = "";
- input.Address.district_city = "";
- input.Address.state_province = "";
- input.Address.country = "";
- input.Address.postal_Code = "";
- }
Steps to follow in your Salesforce account to allow OAuth access to the Zoho Creator application.