Thanks for the reply. I’m new to this if you couldn’t already tell. I am still receiving a failure notice, I’m not sure where I’m going wrong. I will paste the email below. A few other questions:
Do you think I am messing up the mapping?
I already have the field names on my Google Sheet, should I delete these?
Does this form seem correct to you or do I not even need this code?:
function doPost(e) {
if (!e) return;
var sheetID = "1_pextohBKnlOyWvuD3bwypdXSX7ZqHBnf7zvFjB7jkw"; // Replace this with the Google Spreadsheet ID
var sheetName = "Gravity Forms Test Sheet"; // Replace this with the sheet name inside the Spreadsheet
var status = {};
// Code based on Martin Hawksey (@mhawksey)'s snippet
var lock = LockService.getScriptLock();
lock.waitLock(30000);
try {
var sheet = SpreadsheetApp.openById(sheetID).getSheetByName(sheetName);
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
// Add the data and time when the Gravity Form was submitted
var column, row = [],
input = {
"timestamp": new Date()
};
for (var keys in e.parameter) {
input[normalize_(keys)] = e.parameter[keys];
}
for (i in headers) {
column = normalize_(headers[i])
row.push(input[column] || "");
}
if (row.length) {
sheet.appendRow(row);
status = {
result: "success",
message: "Row added at position " + sheet.getLastRow()
};
} else {
status = {
result: "error",
message: "No data was entered"
};
}
} catch (e) {
status = {
result: "error",
message: e.toString()
};
} finally {
lock.releaseLock();
}
return ContentService
.createTextOutput(JSON.stringify(status))
.setMimeType(ContentService.MimeType.JSON);
}
function normalize_(str) {
return str.replace(/[^\w]/g, "").toLowerCase();
}
Really sorry for the long post I just want to figure this out. I appreciate your help. Here is the failure email I received:
There was an error when trying to integrate with the 3rd party service {Service 1} (https://script.google.com/macros/s/AKfycbyWce3ApBXG2CwobvA4e4hAYoTDhzwDdgsRqc_SIbP89klDCDox/exec).
**FORM**
Title: SIGNUP NOW
Intended Recipient: –na–
Source: http://hotjobing.com/browse-jobs/?search_keywords&search_location&search_category=22
**SUBMISSION**
Array
(
[timeout] => 10
[body] => Array
(
[First Name] => Tom
[Last Name] => Cotroneo
[Email Address] => tomcotroneo@gmail.com
[Phone Number] => (973) 303-0477
[Job Category] => E-Commerce
[Edu. Level] => Completed HS or Ged
[Interested In] => Yes
)
)
**RAW RESPONSE**
Array
(
[headers] => Array
(
[content-type] => text/html; charset=UTF-8
[content-length] => 1555
[date] => Wed, 27 Jul 2016 18:52:16 GMT
)
[body] => <!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content=”initial-scale=1, minimum-scale=1, width=device-width”>
<title>Error 400 (Bad Request)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<span id=logo aria-label=Google></span>
<p><b>400.</b> <ins>That’s an error.</ins>
<p>Your client has issued a malformed or illegal request. <ins>That’s all we know.</ins>
[response] => Array
(
[code] => 400
[message] => Bad Request
)
[cookies] => Array
(
)
[filename] =>
[safe_message] => physical request failure
)