Created
April 23, 2020 16:37
-
-
Save matsubo/06deb0519da53cb8f95c9bc878a518ff 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
function scheduleShifts() { | |
var spreadsheet = SpreadsheetApp.getActiveSheet(); | |
var calendarId = spreadsheet.getRange("A2").getValue(); | |
var eventCal = CalendarApp.getCalendarById(calendarId); | |
var signups = spreadsheet.getRange("A5:D12").getValues(); | |
for ( x=0; x < signups.length; x++) { | |
var shift = signups[x]; | |
var startTime = new Date(shift[0]); | |
var endTime = new Date(shift[1]); | |
var title = shift[2]; | |
var options = { | |
description: shift[3] | |
}; | |
console.info(shift); | |
eventCal.createEvent(title, startTime, endTime, options); | |
} | |
} | |
function onOpen() { | |
var ui = SpreadsheetApp.getUi(); | |
ui.createMenu('Sync to Calendar') | |
.addItem('Schedule shifts', 'scheduleShifts') | |
.addToUi(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment