I created a script that copies events from a google sheet and ads it to the calendar. Every time the sheet is updated the calendar needs to be updated. The problem is that the events are duplicated every time the script runs, i don’t want duplicates. Below the code:
function copyCalender() {
var spreadsheet = SpreadsheetApp.getActiveSheet()
var eventCal = CalendarApp.getCalendarById("[email protected]");
var signups = spreadsheet.getDataRange().getValues();
for(x=0;x<signups.length;x++) {
var notAvailable=signups[x]
var busy = notAvailable[0]
var startTime = notAvailable[1]
var endTime = notAvailable [2]
eventCal.createEvent(busy, startTime, endTime);
}
}
i expect the code to not dublicate events and only copy new events.
New contributor
Tijs Van den Broeck is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.