Troubleshooting of google apps script

From LemonWiki共筆
Revision as of 22:34, 24 May 2022 by Planetoid (talk | contribs) (Created page with "Troubleshooting of google apps script about CalendarApp == Fix: TypeError: Cannot read property 'createEvent' of null == Code <pre> let cal = CalendarApp.getCalendarById(cale...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Troubleshooting of google apps script about CalendarApp

Fix: TypeError: Cannot read property 'createEvent' of null

Code

let cal = CalendarApp.getCalendarById(calendar_id);
let event = cal.createEvent(title, start_time, end_time);


Error message

TypeError: Cannot read property 'createEvent' of null
setUpCalendar	@ 程式碼.gs:42

Solution: Verify the cal variable is not null.

Code

let cal = CalendarApp.getCalendarById(calendar_id);
Logger.log('The calendar is named "%s".', cal.getName());

Fix: Exception: Action not allowed

Error message

Exception: Action not allowed
setUpCalendar	@ 程式碼.gs:45

Code

let cal = CalendarApp.getCalendarById(calendar_id);
let event = cal.createEvent(title, start_time, end_time, options);

Solution: Verify the gmail account running apps script was allowed to write the google calendar

Fix: TypeError: cal.createEvent(...).createEventFromDescription is not a function

Error message

TypeError: cal.createEvent(...).createEventFromDescription is not a function
setUpCalendar	@ 程式碼.gs:45

Root cause: use the wrong function

Code

let options = {description: description, guests: email_of_guest};
let event = cal.createEvent(title, start_time, end_time, options);

Further reading


Troubleshooting of ...

Template