Problem: How to create leads from google form responses?

We have a google form and we want to create leads from google form responses.

Solution: -To create lead from google form, follow these steps:-
1.Open google Sheet which contains the responses of google form.
2.Click on the Tools tab and then click on the script editor.
Salesforce | Create leads from google form responses

3. New Screen opens like this..
Salesforce | Create leads from google form responses

Write a code to insert data in the salesforce.

Here is the sample code that inserts leads from the google sheet. In this code, we are using HTML that is generated from the web to lead functionality.

In this code, we are fetching the data of the last row entered in google responses sheet.

function SendtoSalesforce() { var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var row = sheet.getLastRow(); var firstname = sheet.getRange(row,2).getValue(); var city = sheet.getRange(row,3).getValue(); var company = sheet.getRange(row,4).getValue(); var email = sheet.getRange(row,6).getValue(); var resp = UrlFetchApp .fetch( ‘https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8’, { method: ‘post’, payload: { ‘oid’ : ‘xxxxxxxxxxx ‘, //salesforce organization id ‘first_name’ : firstname, //lead field firstname ‘last_name’ : city, //lead field name last name ’email’ : email, //lead field name email ‘company’ : company, //lead field name company ‘city’ : city, //lead field name city ‘state’ : ‘testcity’ ////lead field name city //we can add number of fields we want and assign value according to requirements } }); Logger.log(resp.getContentText()); }

3. Click on save button or Press ctrl+s to save the code.
Salesforce | Create leads
4. Click On the Run Button to execute the script. You can execute the script by clicking on the run button or using run tab.
Salesforce | Create leads from google form responses

5. The Leads are created successfully in Salesforce. You can test it in your salesforce. account.