Created
June 16, 2019 18:22
-
-
Save hvalls/50cd425474313b70fef24ab399badc82 to your computer and use it in GitHub Desktop.
Get last form response and call webhook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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