javascriptgoogle-apps-scriptgoogle-calendar-apigoogle-calendar-recurring-events

How do I hide guest list in google calendar using app script


I'm using google app script in google sheet to send a calendar invite to contacts. I've grouped my contacts for the events, so each row has 2 column: Event Name and List of Emails.

Using below function (just an example) in the script editor, I'm able to send all the guests a calendar invite. But the invite shows them the list of all the other invited guests (and their emails).

function createEvent() {
    emailList = ['a@gmail.com','b@gmail.com','c@gmail.com'];
    var startTime = new Date('May 07, 2020 12:00:00 EST');
    var endTime = new Date('May 07, 2020 14:00:00 EST');
    var description = "Here is the link for the webinar: "; 
    var event = {'location': '','description': description,'guests':emailList+',', 'sendInvites':'True'};
    eventCal.createEvent(summary, startTime, endTime, event);
}

Google calendar lets you set hide that list if you create the event manually, I checked google apps script documentation, but I couldn't find anything that can hide the list for guests. Since I don't have much experience with app script, thought may be the stack overflow community can provide me a direction. Please let me know if I'm missing anything. Thanks!


Solution

  • If my understanding is correct, how about this modification?

    In this modification, I used the method of setGuestsCanSeeGuests of Class CalendarEvent.

    Modified script:

    Please modify your script as follows.

    From:

    eventCal.createEvent(summary, startTime, endTime, event);
    

    To:

    eventCal.createEvent(summary, startTime, endTime, event).setGuestsCanSeeGuests(false);
    

    Note:

    Reference: