Skip to content

Instantly share code, notes, and snippets.

@hvalls
Created June 16, 2019 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hvalls/50cd425474313b70fef24ab399badc82 to your computer and use it in GitHub Desktop.
Save hvalls/50cd425474313b70fef24ab399badc82 to your computer and use it in GitHub Desktop.
Get last form response and call webhook
function onFormSubmit(e) {
var url = //TODO;
var formId = //TODO;
var form = FormApp.openById(formId);
var formResponses = form.getResponses();
var formResponse = formResponses[formResponses.length - 1];
var itemResponses = formResponse.getItemResponses();
var data = itemResponses.map(function(item) {
return { id: item.getItem().getId(), text: item.getItem().getTitle(), response: item.getResponse()};
});
var options = {
"method": "post",
"headers": {
"Content-Type": "application/json"
},
"payload": JSON.stringify(data)
};
var response = UrlFetchApp.fetch(url, options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment