this question related question asked here, example not use calendar app, advanced calendar services
i stuck on how prevent duplicates appearing because geteventseriesbyid not work here.
function onopen() { var sheet = spreadsheetapp.getactivespreadsheet(); var entries = [{ name : "export events", functionname : "exportevents" }]; sheet.addmenu("calendar actions", entries); }; function exportevents() { var sheet = spreadsheetapp.getactivespreadsheet().getsheetbyname("calendar"); var headerrows = 1; var range = sheet.getdatarange(); var data = range.getvalues(); var calid = 'my_id'; (i=0; i<data.length; i++) { if (i < headerrows) continue; var row = data[i]; var date = row[0]; var enddate = row[1]; var title = row[2]; var desc = row[3]; var id = row[4]; var color = row[5]; var newevent = { summary: title, description: desc, "start": { "date": date }, "end": { "date": enddate }, colorid: color }; newevent = calendar.events.insert(newevent, calid); row[4] = newevent.id /* //this bit not work if (id === 1) { var delevent = calendar.events.remove(calid, id); delevent.execute; } */ range.setvalues(data); } }
here's 1 solution:
function onopen() { var sheet = spreadsheetapp.getactivespreadsheet(); var entries = [{ name : "export events", functionname : "exportevents" }]; sheet.addmenu("calendar actions", entries); }; function exportevents() { var sheet = spreadsheetapp.getactivespreadsheet().getsheetbyname("calendar"); var headerrows = 1; var range = sheet.getdatarange(); var data = range.getvalues(); var calid = 'insert cal id'; (i=0; i<data.length; i++) { if (i < headerrows) continue; var row = data[i]; var date = row[0]; var enddate = row[1]; var title = row[2]; var desc = row[3]; var id = row[4]; var color = row[5]; var check = row[6]; var newevent = { summary: title, description: desc, "start": { "date": date }, "end": { "date": enddate }, colorid: color }; newevent = calendar.events.insert(newevent, calid); row[4] = newevent.id if (check == 1) { var delevent = calendar.events.remove(calid, id); } else { newevent.execute; } range.setvalues(data); } }
Comments
Post a Comment