2

I run a seminar series at work. Due to institutional inertia, people find out about these seminars using three separate Google Calendars and are unwilling to either all settle on one or to subscribe to multiple. Currently, I have to copy events from one calendar to the other two manually. Is there any way to automatically forward the contents of one calendar to another? That way I could have one Google Calendar for the seminars, and the other calendars would automatically be updated.

2

There is no concept of forwarding events in Google Calendar. Subscribing to multiple calendars is how people normally deal with this.

But I can offer a Google Apps Script which copies all events within the coming week from source calendar to target calendar. It can be set up with a trigger to run every week, e.g., on Sunday. The calendar Id is found on the Settings page of a calendar.

function copyLastDayEvents() {
  var source = CalendarApp.getCalendarById('....com'); 
  var target = CalendarApp.getCalendarById('....com'); 
  var startPeriod = new Date();        // now
  var endPeriod = new Date();
  endPeriod.setDate(a.getDate() + 7);   // 7 days from now
  var events = source.getEvents(startPeriod, endPeriod);
  for (var i = 0; i < events.length; i++) { 
    var event = events[i];
    var title = event.getTitle();
    if (event.isAllDayEvent()) {
      cal.createAllDayEvent(title, event.getAllDayStartDate());
    }
    else {
      cal.createEvent(title, event.getStartTime(), event.getEndTime());     
    }
    Utilities.sleep(100);    
  }
}

This just loops over the events happening within the coming week, and copies them one by one. Utilities.sleep(100) provides a little pause (100 ms) to avoid hitting Google's rate limit for event creation.

This may be unsatisfactory for several reasons: e.g., events do not appear in the target calendar until the week before. Unfortunately it appears impossible to get all events created today (or within some time period); it's all based on when the events take place.

  • That sounds like it would work, though I'd probably go for a longer timescale than a week (for example updating the year's worth of events, checking each week for new ones). If it adds the same event multiple times, will it automatically ignore the duplicate event? Or is there a way to add something to the script that makes it do that? – Matt Jul 30 '17 at 13:15
  • For a quick solution, you can use the setTag method to set a tag on the copied events, and ignore those in future copies. – cmbuckley Apr 9 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.