Can anyone help me alter this code? I would like to be able to change the color if the calendar title starts with ‘the first four charcters’ of the title name.
For example: If calendar title begins with ‘AOBM’ then make the title ORANGE.
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[0] == "!") {
e.setColor(CalendarApp.EventColor.RED);
}
if (title[0] == '#') {
e.setColor(CalendarApp.EventColor.GREEN);
}
}
}
}