first time asking something here! :)
So I wrote/copied a short script to add an event to my Google Calendar:
function createCalendarEvent() {
var sheet = SpreadsheetApp.getActiveSheet();
var calendar = CalendarApp.getCalendarById('FooBar');
var startRow = 2; // First row of data to process - 2 exempts my header row
var numRows = sheet.getLastRow(); // Number of rows to process
var numColumns = sheet.getLastColumn();
var dataRange = sheet.getRange(startRow, 1, numRows-1, numColumns);
var data = dataRange.getValues();
var complete = "Done";
for (var i = 0; i < data.length; i) {
var row = data[i];
Logger.log(row[0]);
var name = row[0]; //Item Name
var notes = row[3]; //Notes
var startDate = new Date(row[1]); //renewal date
var endDate = new Date(row[2]); //remind date
var eventID = row[6]; //event marked Done
if (eventID != complete) {
var currentCell = sheet.getRange(startRow i, numColumns);
calendar.createEvent(name, startDate, endDate, {
description: notes
});
currentCell.setValue(complete);
}
}
}
This works great, but isn't really the solution to my problem. So straight to my question: Is it posible to add events to someone elses calendar (maybe with ICAL?)
Also my Sheet looks like that: Screenshot
CodePudding user response:
If you have edit rights on the imported calendar then you can add a event to it. Just change the id (FooBar
) to the right one. With this little script you output the calanders with some info to the console.
function readCalanders () {
CalendarApp.getAllCalendars().forEach(cal => {
console.log({
name: cal.getName(),
id: cal.getId(),
primary: cal.isMyPrimaryCalendar(),
owendByMe: cal.isOwnedByMe()
})
})
}