Comments on: Colour code Google calendar events automatically using Google Apps Script https://isbyr.com/colour-code-google-calendar-events-automatically-using-google-apps-script/ Infrequent Smarts by Reshetnikov Sat, 03 Sep 2022 13:00:40 +0000 hourly 1 https://wordpress.org/?v=6.7.1 By: Ilya Reshetnikov https://isbyr.com/colour-code-google-calendar-events-automatically-using-google-apps-script/#comment-3581 Sun, 01 Nov 2020 02:36:13 +0000 http://isbyr.com/?p=406#comment-3581 In reply to JAMIE WATKINS.

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

]]>
By: JAMIE WATKINS https://isbyr.com/colour-code-google-calendar-events-automatically-using-google-apps-script/#comment-3119 Fri, 14 Aug 2020 17:50:01 +0000 http://isbyr.com/?p=406#comment-3119 **Please note…I am not a coder and simply figured out how to do what you had posted**

This code worked for me from August 4-August 12, 2020, but has suddenly stopped working. Any suggestions?

]]>
By: Ilya Reshetnikov https://isbyr.com/colour-code-google-calendar-events-automatically-using-google-apps-script/#comment-2588 Tue, 03 Dec 2019 05:31:10 +0000 http://isbyr.com/?p=406#comment-2588 In reply to David.

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

]]>
By: David https://isbyr.com/colour-code-google-calendar-events-automatically-using-google-apps-script/#comment-2587 Mon, 02 Dec 2019 21:04:21 +0000 http://isbyr.com/?p=406#comment-2587 Hey, Im trying to create a script that changes the color automatically based on the Even Title.
Say:
if the title contains the word “ORANGE” then i want to change the color of the even to “TANGERINE” (dont think they actually have orange)
And if i get another event, with title RED, then i would want to change the color to RED

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);
}
}
}
}

]]>
By: Ilya Reshetnikov https://isbyr.com/colour-code-google-calendar-events-automatically-using-google-apps-script/#comment-2549 Thu, 24 Oct 2019 19:25:51 +0000 http://isbyr.com/?p=406#comment-2549 In reply to Alex.

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 .

]]>
By: Alex https://isbyr.com/colour-code-google-calendar-events-automatically-using-google-apps-script/#comment-2540 Fri, 18 Oct 2019 06:33:16 +0000 http://isbyr.com/?p=406#comment-2540 I tried entering this, and Google complained I was missing a }

]]>