Adam Fithian
Adam Fithian

Reputation: 1

Get Time In and Time Out from google sheets

I am currently trying to write a script to take my users submissions from a google form to sheets then use script editor to create the reservations on a calendar. I have gotten the form portion to work where it dumps the data into a sheet but I am having a hard time with writing the code when it comes getting the the reserved time that the teacher wants to start and then the time that they expect to be done at.

// Hanna Springs Reservation
// Adam Fithian

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var lastRow = sheet.getLastRow();
var lastColumn = sheet.getLastColumn();




// Creates objects from user submissions
function Submission(){
  var row = lastRow;
  this.date = sheet.getRange(row, 2).getValue();
  this.startTime = sheet.getRange(row, 3).getValue();
  this.endTime = sheet.getRange(row, 4).getValue();
  this.Location = sheet.getRange(row, 5).getValue();
  this.Name = sheet.getRange(row, 6).getValue();
  return this;


  }


  //------------main-------------------

function main(){
  var request = new Submission();
  Logger.log(date);
  }

Spreadsheet

Upvotes: 0

Views: 126

Answers (1)

Cooper
Cooper

Reputation: 64082

I'm not sure what you're shooting for but perhaps this feeble attempt can get you started:

function Submission(e){
  var sObj={timesstamp:e.values[0],pickadate:e.values[1],timein:e.values[2],timeout:e.values[3],location:e.values[4],name:e.values[5]};
  var cal=CalendarApp.getCalendarById("id");
  cal.createEvent(sObj.name, sObj.timein, sObj.timeout, {location:sObj.location});
}

Upvotes: 1

Related Questions