AppsScript execution complete but nothing happens

I have this script to automate the creation of events to a specific calendar shared with my team.
The execution is always completed without any errors, however, the events are not created at all. Can someone help me to identify where the issue is?
 
Here is the script:
 
const calendarId = ("TheIDGoesHere");
const uniqueEventSuffix = "[CONTRACTS RENEWAL]";
const dataRange = "A2:E";
 
function deleteAutoCreatedEvents() {
  var eventCal = CalendarApp.getCalendarById("TheIDGoesHere");
  var startOfCurrentYear = new Date(new Date().getFullYear(), 0, 1);
  var endOfCurrentYear = new Date(new Date().getFullYear(), 11, 31)
  var events = eventCal.getEvents(startOfCurrentYear, endOfCurrentYear);
  for(var i=0; i < events.length; i++) {
    var ev = events[i];
    var title = ev.getTitle();
    if (title.indexOf(uniqueEventSuffix) >-1) {
      ev.deleteEvent();
    }
  }
}
 
function addEventsToCalendar() {
  var spreadsheet = SpreadsheetApp.getActiveSheet();
  var eventCal = CalendarApp.getCalendarById("TheIDGoesHere");
  var rawEvents = spreadsheet.getRange("d:e").getValues();
  var events = rawEvents.filter(function(r){
    return r.join("").length > 0;
  });
 
  deleteAutoCreatedEvents();
 
}
 
 
On the spreadsheet, the columns where the Start Date and the End Date of a contract are in columns D and E, in the format of M/DD/YYYY H:MM:SS. This script should trigger events in the calendar with a notice of 90-30-15-7-2 days, based on the End Date.
1 1 166
1 REPLY 1

Does it run correctly if you run it manually (not calling it from AppSheet)?

Top Labels in this Space