Reputation: 13
I am trying to change the color of some individual calendar events that start with the word "Klausur". There seems to be a problem with the setColor() method. But I cant figure out why. If I call the method on the entire calendar it dose work but on individual events it dose not.
function changeKlausurColor() {
var now = new Date();
var start = new Date(now.getTime() - (604800 * 1000 * 52));
var end = new Date(now.getTime() + (604800 * 1000 * 52));
var srcCal = CalendarApp.getCalendarById("CalendarID");
var events = srcCal.getEvents(start, end);
for (var i in events) {
if (events[i].getTitle().indexOf("Klausur") == 0) {
var color = events[i].setColor("#0D7813");
}
}
}
Upvotes: 0
Views: 2608
Reputation: 201493
You can select the event color from Enum EventColor. When this is reflected to your script, please modify as follows.
var color = events[i].setColor("#0D7813");
var color = events[i].setColor(CalendarApp.EventColor.GREEN);
Upvotes: 2