Okay, first of all, what I'm trying to do is updating Google sheet and calendar simultaneously. So, let say if there's an update to your spreadsheet there will also be an update to the calendar. However, here's all the things that I failed to do.
- If there's changes in the calendar , there will be no changes in the spreadsheet
- I'm unable to find code to invite guest to the calendar. So far , all i know is that i need to to use " attendee[] " but I'm unable to find example to show me on how its done. I've found some java code but its different if I'm not mistaken.
So, these will be the order for the spreadsheet
Date Title Start Time End Time Location Description Guest EventID
This one is the code on the google sheets.
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Export Events",
functionName : "exportEvents"
}];
sheet.addMenu("Calendar Actions ", entries);
};
function exportEvents() {
var sheet = SpreadsheetApp.getActiveSheet();
var headerRows = 1;
var range = sheet.getDataRange();
var data = range.getValues();
var calId = "muiznn@gmail.com"; // calenderID
var cal = CalendarApp.getCalendarById(calId);
for (i in data) {
if (i < headerRows) continue;
var row = data[i];
var date = new Date(row[0]);
var title = row[1];
var tstart = new Date(row[2]);
tstart.setDate(date.getDate());
tstart.setMonth(date.getMonth());
tstart.setYear(date.getYear());
tstart.setMinutes( tstart.getMinutes() + 6)
var tstop = new Date(row[3]);
tstop.setDate(date.getDate());
tstop.setMonth(date.getMonth());
tstop.setYear(date.getYear());
tstop.setMinutes(tstop.getMinutes() + 6)
var loc = row[4];
var desc = row[5];
var guest = row[6]
var id = row[7];
try
{
var event = cal.getEventSeriesById(id);
event.deleteEventSeries();
row[7] = '';
}
catch (e) {
}
var newEvent = cal.createEvent(title, new Date(tstart), new Date(tstop), {description:desc,location:loc}).getId();
row[7] = newEvent;
debugger;
}
range.setValues(data);
}
If possible , I would some guidance on this , since I'm stuck.