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

339
Views
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 answers
Answer question

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 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!