Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

281
Views
Configured a script that automatically colourcodes your calender, but hit a snag

This javascript is something I configured to be used for Google Calendar. It automatically makes your private invites, private and colour coded. This works perfectly.

At the sametime I want to colourcode all the invites I get from external companies/partners. This I can't seem to make work. I tried .includes(), but those require exact strings which I don't have. The current code pretty much marks all events right now instead of the intended external email domains.

 function ColorEvents() {
 
  var today = new Date();
  var nextmonth = new Date();
  nextmonth.setDate(nextmonth.getDate() + 31);
  Logger.log(today + " " + nextmonth);
 
  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, nextmonth,);
    for (var j=0; j<events.length; j++) {
      var e = events[j];
      var title = e.getTitle();
      var creator = e.getCreators();
      var guest = e.getGuestList();
     if (!creator.indexOf(/@company.net|@partner.nl|@daughtercompany.net/)) {
       e.setColor(CalendarApp.EventColor.PALE_BLUE);
      }   
    if (creator.includes("myemail@company.net") &&!title.includes("Lunch") ) {
      e.setColor(CalendarApp.EventColor.PALE_GREEN);
      } 
    if (creator.includes("wife@gmail.com") || guest.includes("wife@gmail.com")) {
      e.setColor(CalendarApp.EventColor.PALE_RED).setVisibility(CalendarApp.Visibility.PRIVATE);;
      }
    if (creator.includes("boyfriend@gmail.com")) {
      e.setColor(CalendarApp.EventColor.PALE_RED).setVisibility(CalendarApp.Visibility.PRIVATE);
      }
    if (title.includes("Lunch") || (title.includes("Block"))) {
      e.setColor(CalendarApp.EventColor.GRAY);
    }
  }
}
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!