PDA

View Full Version : Updating Google Calendars from a Google Spreadsheet



griffinlross
08-09-2017, 10:52 AM
I’ve been trying to run a script in order to sync my google spreadsheet with my google calendar, however, I get the error message: Cannot find method createEvent(string,string,string,object). (line 15, file "Code")

The script that I entered is:
function caltest1() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2;
var numRows = 199;
var dataRange = sheet.getRange(startRow, 1, numRows, 5);
var data = dataRange.getValues();
var cal = CalendarApp.getDefaultCalendar();
for (i in data) {
var row = data[i];
var title = row[2];
var desc = row[3];
var tstart = row[1];
var tstop = row[1];
var loc = row[3];
cal.createEvent(title, tstart, tstop, {description:desc,location:loc});
}
}

There is a total of 199 rows not including the header row. I have date/time in the first row, the event in the second, and the country where the event is taking place in the third column. Can you let me know how I can run this so it imports all the events into a google calendar I have created and updates automatically when new events are entered into the spreadsheet? The google spreadsheet was from an excel file I imported.

mdmackillop
08-10-2017, 10:54 AM
Maybe not the best Forum for this question.

briandon123
04-17-2020, 07:08 AM
There's a no-script alternative to this called Automate.io. But there's a catch. - it can only add new rows to your calendar.

https://automate.io/integration/google-calendar/google-sheets