Last active
August 14, 2019 12:04
-
-
Save ChaiyachetU/3916b2fe47c988a16c1448b3f7bf8edd to your computer and use it in GitHub Desktop.
Test booking form project. Get data from Google form with link to Google Sheet and Create Event on Google Calendar.
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
// Calendar Booking Project | |
// Chaiyachet Ukham, 2019 | |
// All rights reserved | |
// Get data from google form with link to google sheet and create event from sheet version 1.0 | |
function addBooking() { | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = ss.getActiveSheet(); | |
var lastRow = sheet.getLastRow(); | |
var lastColumn = sheet.getLastColumn(); | |
// Creates output requests from the last form submission | |
var name = sheet.getRange(lastRow, 2).getValue(); | |
var phoneNumber = sheet.getRange(lastRow, 3).getValue(); | |
var roomNumber = sheet.getRange(lastRow, 4).getValue(); | |
var startDate = new Date(sheet.getRange(lastRow, 5).getValue()); | |
var endDate = new Date(sheet.getRange(lastRow, 6).getValue()); | |
// Calendar to output requests | |
var calendar = CalendarApp.getCalendarById(google calendar Id); | |
//Creates a calendar event using the submitted data | |
var titles = (name + ' ' + 'Tel.' + phoneNumber); | |
var descriptions = roomNumber; | |
calendar.createEvent(titles, startDate, endDate, {description: descriptions}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment