title: Event will not delete (Google Scripts with Calendar API)
body: <p>I am creating a script that takes an existing Google Calendar and matches another calendar with its information. For example, if an event is added in the existing calendar, the other calendar will add an event. If an event date is altered in the existing calendar, the other calendar will delete the event that previously matched and create one to match the altered event. I am having trouble with deleting the events.</p>
  <p>I am unsure why I get the error &quot;Failed with error listed_event.deleteEvent is not a function&quot;. I have tried for a few days and still have no clue what the issue could be in my code. The line in question is bolded with asterisks, although I have suspicions the issues lie elsewhere.
  Any help would be greatly appreciated.</p>
  <pre><code>function CleaningCalendar() {
    const CleaningId = 'primary';
    // Add query parameters in optionalArgs
    const HospitableId = 's4h3vvv6r47c3uqiknjhr4hrprgjua5g@import.calendar.google.com';
  
    const optionalArgs = {
      timeMin: (new Date()).toISOString(),
      showDeleted: false,
      singleEvents: true,
      maxResults: 300,
      orderBy: 'startTime'
      // use other optional query parameter here as needed.
    };
    try {
      // call Events.list method to list the calendar events using calendarId optional query parameter
      var HospitableEvents = Calendar.Events.list(HospitableId, optionalArgs).items;
      var CleaningEvents = Calendar.Events.list(CleaningId, optionalArgs).items;
  
      const property_list = [&quot;BREITHAUPT&quot;, &quot;SPRING&quot;, &quot;ELLIS 1&quot;, &quot;ELLIS 2&quot;, &quot;ELLIS 3&quot;, &quot;ELLIS 5&quot;, &quot;UNION 1&quot;, &quot;UNION 2&quot;, &quot;UNION 3&quot;]
     
      if (HospitableEvents.length === 0) {
        Logger.log('No upcoming events found');
        return;
      }
      for (let i = 0; i &lt; HospitableEvents.length; i++){
       
  
        event = HospitableEvents[i];
        const start_date = event.start.dateTime;
  
        //The fourth semi-colon in the Hospitable Calendar event description pertains to the property name
        let first_colon_loc =  event.description.indexOf(&quot;:&quot;);
        let second_colon_loc =  event.description.slice(first_colon_loc + 1).indexOf(&quot;:&quot;);
        let third_colon_loc = event.description.slice(first_colon_loc + second_colon_loc + 2).indexOf(&quot;:&quot;);
        let fourth_colon_loc = event.description.slice(first_colon_loc + second_colon_loc + third_colon_loc + 3).indexOf(&quot;:&quot;);
        let property_colon_loc = first_colon_loc + second_colon_loc + third_colon_loc + fourth_colon_loc + 5;
              
        let end_of_property_name = event.description.slice(property_colon_loc).indexOf(&quot;\n&quot;);
        let property_name = event.description.slice(property_colon_loc, property_colon_loc + end_of_property_name);
        var cleaning_event = {
    'summary': property_name,
    'location': '',
    'description': '',
    'start': {
      'dateTime': start_date,
      'timeZone': 'America/New_York'
    },
    'end': {
      'dateTime': start_date,
      'timeZone': 'America/New_York'
    },
    'recurrence': [
      'RRULE:FREQ=DAILY;COUNT=1'
    ],
    'attendees': [''],
    'reminders': {
      'useDefault': false,
      'overrides': [
        {'method': 'email', 'minutes': 24 * 60},
        {'method': 'popup', 'minutes': 10}
      ]
    }
  };
      
        if (property_list.includes(property_name)){
          count = 0
          for (let i = 0; i &lt; CleaningEvents.length; i++){
            if ((property_name == CleaningEvents[i].summary) &amp;&amp; (event.start.dateTime == CleaningEvents[i].start.dateTime)){
              count = count + 1;
              continue;
        }}
          if (count == 0){
           created_event = CalendarApp.getDefaultCalendar().createEvent(property_name,
      new Date(start_date),
      new Date(start_date));
      }}
        else{
          Logger.log(HospitableEvents[i]);
          Logger.log(&quot;The above is not valid&quot;);
      }
  
  
    }
      for (let k = 0; k &lt; CleaningEvents.length; k++){
       listed_event = CleaningEvents[k];
       var count = 0;
       for (let j = 0; j &lt; HospitableEvents.length; j++){
         event = HospitableEvents[j];
          const start_date = event.start.dateTime;
  
          //The fourth semi-colon in the Hospitable Calendar event description pertains to the property name
          let first_colon_loc =  event.description.indexOf(&quot;:&quot;);
          let second_colon_loc =  event.description.slice(first_colon_loc + 1).indexOf(&quot;:&quot;);
          let third_colon_loc = event.description.slice(first_colon_loc + second_colon_loc + 2).indexOf(&quot;:&quot;);
          let fourth_colon_loc = event.description.slice(first_colon_loc + second_colon_loc + third_colon_loc + 3).indexOf(&quot;:&quot;);
          let property_colon_loc = first_colon_loc + second_colon_loc + third_colon_loc + fourth_colon_loc + 5;
                
          let end_of_property_name = event.description.slice(property_colon_loc).indexOf(&quot;\n&quot;);
          let hospitable_name = event.description.slice(property_colon_loc, property_colon_loc + end_of_property_name);
  
          
          if ((listed_event.summary == hospitable_name) &amp;&amp; (listed_event.start.dateTime == event.start.dateTime)){
            count = count + 1;
            continue;
          }
      
          }
        if (count == 0){
  
            **listed_event.deleteEvent();**
  
            Logger.log(listed_event);
  
          }}
      }
    catch (err) {
      // TODO (developer) - Handle exception from Calendar API
      Logger.log('Failed with error %s', err.message);
    }
  }
  </code></pre>