Forked from psychemedia/webhook demo for Google spreadsheet onFormSubmit event
Created
October 27, 2016 15:31
-
-
Save sadortun/453aa1d390f1ce624113985f465f6a36 to your computer and use it in GitHub Desktop.
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
// Simple spreadsheet, with first sheet containing form submission repsonses | |
// when the form is submitted: | |
// 1) grab the latest response, | |
// 2) post it to a third party service via an HTTP POST | |
function testWebhook() { | |
var ss = SpreadsheetApp.openById(SPREADSHEET_ID); | |
var form=ss.getSheets()[0]; | |
var lr=form.getLastRow(); | |
var el=form.getRange(lr,2,1,1).getValue(); | |
var t=el; | |
//The following escape palaver is gleaned from a Google help forum... | |
var p="val1="+encodeURIComponent(t).replace(/%20/g, "+")+"&val2="+encodeURIComponent(form.getRange(lr,3,1,1).getValue()).replace(/%20/g, "+"); | |
// Here's where we do the callback... | |
var x=UrlFetchApp.fetch('http://www.postbin.org/YOURPASTEBINID',{method: 'post', payload: p}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment