Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

349
Vistas
TypeError: Cannot read property 'getEventById' of null

At first, I am a very new programmer, so I apologize for my ignorance. I wrote this code using google apps script to take data from a google sheet, and import that to a calendar.

var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Class");
var data = sheet.getDataRange().getValues();
var today = Utilities.formatDate(new Date(), "GMT+9", "yyyy-MM-dd");

function caldel() {
  var eventCal = CalendarApp.getCalendarById('//gmail address'); 
  for (var i=73; data.length; i++) {
    var evtcall = eventCal.getEventById(data[i][52]);
    evtcall.deleteEvent();

  }
}

It used to run well, but today, error message poped up.

"TypeError: Cannot read property 'getEventById' of null
caldel  @ Code.gs:8"

I don't know why this error came out. If there is anyone who knows or fixes this error, plz help me. Thank you.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Assumming that you are using a real calendar id (like Gmail address) in

var eventCal = CalendarApp.getCalendarById('//gmail address'); 

you are getting null assigned to eventCal because the effective user don't have access to the referred calendar.

  1. Validate that you can access the calendar with the account that you are using to run the script.

As a rule of thumb avoid sign-in into multiple accounts when running a Google Apps Script function. This because calling a server-side function from a dialog, sidebar or web-app might be done using the default account instead of the account that has access to the required resources.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda