// Configure your CRM URL and API key var CRM_URL = 'https://nistally.sangamcrm.com/api/v1/save-data'; var API_KEY = 'o2xg6kCMqmSMpXqvB1hYLvBaQnfC2iTD'; // Form submission event handler function onSubmit(e) { // Retrieve form response data var response = e.response; var itemResponses = response.getItemResponses(); // Extract field values from form response var firstName = itemResponses[0].getResponse(); var accountID = itemResponses[1].getResponse(); var contactc = itemResponses[2].getResponse(); var phone = itemResponses[3].getResponse(); var email = itemResponses[4].getResponse(); var industry = itemResponses[5].getResponse(); Logger.log(firstName); Logger.log(accountID); // Create the lead data object var leadData = { 'module_name': 'Lead', 'field_name_list': { 'first_name': firstName, 'account_id': accountID, 'contact_c': contactc, 'phone': phone, 'email': email, 'industry': industry }, // Send lead data to CRM using API var options = { method: 'post', contentType: 'application/json', headers: { 'Authorization': 'Bearer ' + API_KEY }, payload: JSON.stringify(leadData) }; var response = UrlFetchApp.fetch(CRM_URL, options); Logger.log(response.getContentText()); } function onFormSubmitAuto(e) { onSubmit(e); }