I am not too sure Jamie,
I do recall that it also stopped once working for me, then I went back to the Developer Hub and I think it was asking for my permissions (maybe Google has updated the permissions model or something).
I can’t recall from on top of my head where was it in the Hub
This code worked for me from August 4-August 12, 2020, but has suddenly stopped working. Any suggestions?
]]>Hi David,
I haven’t dived into the details of your code, but in the beginning you are mentioning “if the title contains the word..” while later in the code you are comparing if the title equals.
See if that might be the issue also try to add Logger statements
The below code doesn’t seem to be working.
function ColorEvents() {
var today = new Date();
var nextweek = new Date();
nextweek.setDate(nextweek.getDate() + 7);
Logger.log(today + ” ” + nextweek);
var calendars = CalendarApp.getAllOwnedCalendars();
Logger.log(“found number of calendars: ” + calendars.length);
for (var i=0; i<calendars.length; i++) {
var calendar = calendars[i];
var events = calendar.getEvents(today, nextweek);
for (var j=0; j<events.length; j++) {
var e = events[j];
var title = e.getTitle();
if (title[0] == "[") {
e.setColor(CalendarApp.EventColor.CYAN);
}
if (title == "orange") {
e.setColor(CalendarApp.EventColor.TANGERINE);
}
if (title[0] == '#') {
e.setColor(CalendarApp.EventColor.GREEN);
}
}
}
}
Hi Alex,
Looks like some character encoding creeped in when copy/pasted to the blog
please replace these 2 lines
if (events.length > 0) {
for (i = 0; i < events.length; i++) {
with these
if (events.length > 0) {
for (i = 0; i < events.length; i++) {
or just copy the whole snipped agin, I've updated it.
Thank you for your feedback .