Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Google AppsScript: eliminar eventos recurrentes (eventSeries) de Google Calendar

Tengo el siguiente código que elimina eventos de mi calendario de Google que están marcados como Pending Removal en las hojas de Google. La parte de este código que elimina eventos únicos funciona bien, pero también necesito modificarla para eliminar eventos recurrentes. En este momento, solo elimina el primer evento de la serie de eventos recurrentes.

Nota: los eventos se indican como pendientes de eliminación en la Column E o ```x[4]``. ingrese la descripción de la imagen aquí

 function calendarRemove() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var dataSheet = ss.getSheetByName('Events Calendar') var settingsSheet = ss.getSheetByName('Calendar Settings'); var calendarId = 'calendarID'; var eventCal = CalendarApp.getCalendarById(calendarId); var eventArray = dataSheet.getRange('A2:H').getDisplayValues(); for (x = 0; x < eventArray.length; x++) { var event = eventArray[x]; var eventName = event[1]; var eventDate = new Date(event[0]); var timeZone = event[6]; var startTime = new Date(`${event[0]} ${event[2]} ${timeZone}`); var endTime = new Date(`${event[0]} ${event[3]} ${timeZone}`); var status = event[4]; // Used in the following comparison expression if (status === 'Pending Removal') { var returnedEvents = eventCal.getEventsForDay(eventDate, {search: eventName}); for (i = 0; i < returnedEvents.length; i++) { var toRemove = returnedEvents[i]; if (toRemove.isRecurringEvent) { toRemove.deleteEventSeries(); } else { toRemove.deleteEvent(); } eventArray[x][4] = 'Removed'; // Modifying the status value from "Pending Removal" to "Removed" } } } dataSheet.getRange('A2:H').setValues(eventArray); // Overwrite the source data with the modified array }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hay un hilo que señala ese problema, donde primero debe eliminar la recurrencia del evento y luego eliminar el resto en el bucle en el script de Google Calendar: eliminar recurrencia

Este script podría ayudarte, al final del hilo anterior.

 function deleteEvents() { var calendarName = '<Name of the Calendar>'; var calendar = CalendarApp.getCalendarsByName(calendarName)[0]; var events = calendar.getEvents('<Sheet events where recurring events is set to "Yes">'); for(var i=0; i < events.length;i++) { var ev = events[i]; Logger.log('Checking Event Title === ' + calendar.getEventSeriesById(ev.getId()).getTitle()); calendar.getEventSeriesById(ev.getId()).deleteEventSeries(); Logger.log('Event Deleted'); } }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!