Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

336
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda