My script is working, but is getting this error everytime and I couldn’t find the root cause for it. I’m new here and would appreciate if someone could point out my mistake.
TypeError: Cannot read properties of null (reading ‘createAllDayEvent’)
Script Janeiro.gs:12
function month01(){
// get Calendar ID
let sheet = SpreadsheetApp.getActiveSheet()
let id = SpreadsheetApp.getActive().getRangeByName("CalendarID").getValue()
// get Event data...the filter allows us to only get rows that contain data, and to exclude the checkbox in the filter
let events = SpreadsheetApp.getActive().getRangeByName("EventList01").getValues().filter(array => array.slice(0, -1).some(value => value !== ''));
//single day event with just title and date
events.forEach( function(e, index){
if(!e[22]){
CalendarApp.getCalendarById(id).createAllDayEvent(
e[2],
e[0],
{description: e[1]})
let newIndex = index+3;
sheet.getRange("AB"+ newIndex).setValue(true)
}
})
}
Thanks for helping!
New contributor
Tomás Albuquerque is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.