EventGuest.getGuestStatus(true) never returns "Owner"

Skip to first unread message

Nicholas Cacia

Apr 5, 2022, 3:27:31 AMApr 5
to Google Apps Script Community
I'm having an issue where I cannot get EventGuest.getGuestStatus(true) to ever show me who the "Owner" of an event is. 

Each time I call this, I see "Yes" for the person who is the owner of the event.

As a quick example:
function testingGuestStatus() {
   var event = CalendarApp.getEventById('someRandomEventIdHere');
   var guestList = event.getGuestList(true);

  for (var i = 0; i <= guestList.length; i++){
    var guest = guestList[i].getEmail();
    var status = guestList[i].getGuestStatus().toString();
    Logger.log(guest + ' ' + status);



This will always log "YES", "NO", or "INVITED" as far as I have seen, but never "OWNER" despite what the documentation states:

Am I doing something wrong, or is the API not working correctly?


Martin Hawksey

Apr 5, 2022, 4:12:01 AMApr 5
to Google Apps Script Community
Hi Nicholas,

From the limited testing I've done it looks like a limitation of GuestStatus is if the owner accepts then you get YES rather than OWNER.

A workaround could be to get the guest list with and without the owner and compare the two e.g.:

function testingGuestStatus() {
  var event = CalendarApp.getEventById('someRandomEventIdHere');
  var guestList = event.getGuestList(true);
  var guestListWithoutOwner = event.getGuestList(); // get the guest list without the owner

  // filter the guest list to ignore duplicate emails leaving only the owner
  let owner = guestList.filter(o1 => !guestListWithoutOwner.some(o2 => o1.getEmail() === o2.getEmail()));

  Logger.log('The owner is: ' + owner[0].getEmail());

  // Old code
  for (var i = 0i < guestList.lengthi++){
    var guest = guestList[i].getEmail() ? guestList[i].getEmail() : null;

You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/0ccabdd5-d675-46bb-a8a6-4024e1f0eb00n%40googlegroups.com.

Martin Hawksey
Creator, Content Producer and Community Advocate
Totally Unscripted / Apps Script Pulse

Nicholas Cacia

Apr 5, 2022, 10:16:35 AMApr 5
to Google Apps Script Community
Thanks Martin!  I like the workaround idea and will probably implement it that way for now. 

Seems like a pretty odd limitation - as I imagine MOST event Owners will automatically Accept the events that they create.    

Appreciate the quick advice!

Martin Hawksey

Apr 6, 2022, 7:14:28 AMApr 6
to Google Apps Script Community
Hi Nicholas - your Q was so interesting I had to dig a little further and you may prefer using the Calendar Advanced Service

  const event = Calendar.Events.get(CalendarApp.getDefaultCalendar().getId(), 'someRandomEventIdHere');
  Logger.log('The owner is: ' + event.organizer.email); 

Reply all
Reply to author
0 new messages