I'm having a terrible time getting this code to work. I'm learning a lot, but I'm very much a beginner.
Here's the script:
//push new events to calendar function pushToCalendar() { //spreadsheet variables
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange(1,1,5,25);
var values = range.getValues();//calendar variables var calendar = CalendarApp.getCalendarById('xxxx') var numValues = 0; for (var i = 0; i < values.length; i++) { //check to see if name and type are filled out - date is left off because length is "undefined" if ((values[i][0].length > 0) && (values[i][2].length > 0)) { //check if it's been entered before if (values[i][16]!= 'y') { //create event https://developers.google.com/apps-script/class_calendarapp#createEvent var newEventTitle = 'values[i][1]' + ' ' + values[i][15] + ' - ' + values[i][3] + ' - ' + values[i][10] + ' Driver: Needed'; var newEvent = calendar.createAllDayEvent(newEventTitle, values[i][8]); //get ID var newEventId = newEvent.getId(); //mark as entered, enter ID sheet.getRange(i+2,16).setValue('y'); sheet.getRange(i+2,17).setValue(newEventId); } //could edit here with an else statement } numValues++; }
And here's a link to a dummy:
https://docs.google.com/spreadsheets/d/1gBXtHjEhnNSEkJYq2upCWtwkj1ZLWiUYv6KSuMH8Nds/edit?usp=sharing