I'm using the following code to check if there are cancelled events in a Google Calendar. It works fine for regular, non-recurring events. However, I run into issue when the user has deleted a single event in a recurring event series.
function checkForCancelledEvents(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Data Source");
ss.setActiveSheet(sheet);
//sort by date added
var lastRow = sheet.getLastRow();
var range = sheet.getRange(1,2,lastRow, 5)
var values = range.getValues();
//in the array the 3 position is the eventId, the 4 position is the calendar ID, I'm putting more into the array since I was playing around with also using the start date or time to solve the problem
//loop through all using Calendar.Events.get
for (i=1;i<values.length;i++) {
var splitEventID = values[i][3].toString().split("@")[0] //remove the calendarID from the eventID
if (Calendar.Events.get(values[i][4],splitEventID).status === "cancelled") {
//the below clears the content of the row that contains the cancelled events
//the range has to start at i + 1 since the values include the header row, but the for loop starts at 1 instead of 0 to prevent the API from calling with data from header row (which produces an error). So i + 1 gives the accurate row number for which the cancelled event lives
var clearRange = sheet.getRange(i + 1,1,1,7)
clearRange.clearContent()
} else {
//Logger.log("this is NOT cancelled")
}
}
}
The issue is that recurring events all contain the same eventID and calendarID. They have the same iCalUID as well. Recurring events do have a different id but non-recurring events don't have the same id format. I tried to use Calendar.event.list and add the timeMin of each event within the recurring series, however the event was still listed as confirmed even though it was deleted.
Is there a way to find if a single event within a recurring series has been deleted?