first off, thank you so much for posting this! i downloaded a copy with your google test file and it works amazingly well. i tried to edit it to work with my own file, but i can't figure out what i'm doing wrong.
i only want to sync to calendar, so i don't need the entire code... i only have 2 info columns: date and source. i think the part i got stuck on was the index mapping. i'm a noob and still learning to code so i was hoping someone could help me get the right code for my project.
my code is below. i had added your code (sync to calendar) after this section below. i even tried deleting my code and just editing yours with my google calID, but still no good. i think the index mapping is throwing me off. can you kindly provide some guidance?
in my spreadsheet:
column E: date
column F: source
function onEdit() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh0 = ss.getSheetByName("DATA");
var entries = [{
name : "Export Events",
functionName : "addEvents"
}];
ss.addMenu("Calendar Actions", entries);
};
function addEvents(){
var ss = SpreadsheetApp.getActiveSheet();
var headerRows = 1;
var range = ss.getDataRange();
var values = range.getValues();
var data = ss.getRange("D2:E24").getValues();
var cal = CalendarApp.getCalendarById('k8kjmthm3fmcapidh9urkk6h2g@group.calendar.google.com');
var calID = "k8kjmthm3fmcapidh9urkk6h2g@group.calendar.google.com";
//Logger.log(cal);
//Logger.log(data.length);
for(var i = 0;i<data.length;i++){
if (i < headerRows) continue;
var column = data[i];
var row = data[i];
Logger.log(row);
var date = row[0];
//Logger.log(date);
var title = row[1];
var date = row[0];
var id = row[1];
var event = row[1]
var eventSeries = row[1]
var startDate = row[0]
var endDate = row[0]
try {
var event = cal.getEventSeriesById(id);
event.deleteEventSeries();
row[1] = '';
var event = cal.deleteEvent(row[1]);
}
catch (e) {
}
Logger.log(event);
var newEvent = cal.createAllDayEvent(title, startDate).getId();
row[1] = newEvent; // Update the data array with event ID
debugger;
}
}
first off, thank you so much for posting this! i downloaded a copy with your google test file and it works amazingly well. i tried to edit it to work with my own file, but i can't figure out what i'm doing wrong.
i only want to sync to calendar, so i don't need the entire code... i only have 2 info columns: date and source. i think the part i got stuck on was the index mapping. i'm a noob and still learning to code so i was hoping someone could help me get the right code for my project.
my code is below. i had added your code (sync to calendar) after this section below. i even tried deleting my code and just editing yours with my google calID, but still no good. i think the index mapping is throwing me off. can you kindly provide some guidance?
in my spreadsheet: column E: date column F: source
link to sheet: https://docs.google.com/spreadsheets/d/1bypnjudgMpVzftR1k8BWCdSSxBmfZjTN9xh-ItQ5tCM/edit?usp=sharing
function onEdit() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sh0 = ss.getSheetByName("DATA"); var entries = [{ name : "Export Events", functionName : "addEvents" }]; ss.addMenu("Calendar Actions", entries); };
function addEvents(){
var ss = SpreadsheetApp.getActiveSheet(); var headerRows = 1; var range = ss.getDataRange(); var values = range.getValues(); var data = ss.getRange("D2:E24").getValues(); var cal = CalendarApp.getCalendarById('k8kjmthm3fmcapidh9urkk6h2g@group.calendar.google.com'); var calID = "k8kjmthm3fmcapidh9urkk6h2g@group.calendar.google.com"; //Logger.log(cal); //Logger.log(data.length);
for(var i = 0;i<data.length;i++){ if (i < headerRows) continue; var column = data[i]; var row = data[i]; Logger.log(row); var date = row[0]; //Logger.log(date); var title = row[1]; var date = row[0]; var id = row[1]; var event = row[1] var eventSeries = row[1] var startDate = row[0] var endDate = row[0]
} catch (e) { } Logger.log(event);
var newEvent = cal.createAllDayEvent(title, startDate).getId(); row[1] = newEvent; // Update the data array with event ID debugger; } }