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

后端 未结 6 937
后悔当初
后悔当初 2020-12-17 00:55

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.

6条回答
  •  悲&欢浪女
    2020-12-17 01:27

    Allright... In 2020 this is the working version of this in case somebody is still struggling with this...

    var calendarID = "somec@lend.ar";
    var event = CalendarApp.getCalendarById(calendarID).createEvent(/*SOME OPTIONS HERE*/);
    
    var splitEventId = event.getId().split('@');
    
    // Open the "edit event" dialog in Calendar using this URL:
    var event_EDIT_URL = "https://calendar.google.com/calendar/r/eventedit/" + Utilities.base64Encode(splitEventId[0] + " " + calendarID).replace("==",'');
    
    // Open the "view this event in a Calendar" using this URL:
    var event_VIEW_IN_CAL_URL = "https://www.google.com/calendar/event?eid=" + Utilities.base64Encode(splitEventId[0] + " " + calendarID).replace("==",'');
    
    
    return event_EDIT_URL; // OR return event_VIEW_IN_CAL_URL;   
    

提交回复
热议问题