Search code examples
google-calendar-apigoogle-apps-script

Get link (url) to an calendar event in google apps script


I have a Calendar Event in Google Apps Script and I want to allow the user to open it by clicking an Anchor. I think I can the URL has to look like this: http://www.google.com/calendar/event?eid=SOMEID&ctz=Etc/GMT . However I can't seem to get the required ID from the Calendar Event. The ID I get from Event.getId() doesn't work in those URL's and there is no event.getUrl().

Does anyone know if this is possible with apps script?


Solution

  • For given event object of type CalendarEvent and given calendarId, the simplest and working way to build an URL to view/edit corresponding event in Google Calendar App is the following:

    var splitEventId = event.getId().split('@');
    var eventURL = "https://www.google.com/calendar/event?eid=" + Utilities.base64Encode(splitEventId[0] + " " + calendarId);
    

    The best thing is that no Google API invocation, authentication, ... needed!