Skip to content

Instantly share code, notes, and snippets.

View sauntimo's full-sized avatar

Tim Saunders sauntimo

View GitHub Profile
@sauntimo
sauntimo / ObjectPropertyLoop.js
Created November 9, 2012 19:51
Looping through Object Properties
function OnSubmit(e){
var NewSubmission = {};
var Properties = ["Timestamp","Favourite Colour","Explanation"];
var i = 0;
for(i = 0; i < Properties.length; i++){
NewSubmission[Properties[i]] = e.values[i];
}
@sauntimo
sauntimo / TestEmail.js
Created November 9, 2012 17:38
Trigger Test Email
function OnSubmit(e){
MailApp.sendEmail("[email protected]", "Your form was submitted!",
"Hey you!" +
"\n\n Someone submitted your form. Here's what they had to say:" +
"\n\n Favourite Colour: " + e.values[1] +
"\n Explanation: " + e.values[2])
}
@sauntimo
sauntimo / Default.js
Created November 9, 2012 16:05
Default spreadsheet code
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@sauntimo
sauntimo / SetUpObject.js
Created November 9, 2012 12:51
Creating a usable object from a form submission
function formSubmitReply(e) {
/* ----- CREATE NEW OBJECT FROM SUBMISSION ----- */
var NewSubmission = {
"Timestamp" : e.values[0],
"Favourite Colour" : e.values[1],
"Explanation" : e.values[2],
}