App script for calendar access

44 views
Skip to first unread message

vinu t

unread,
Jul 9, 2025, 5:04:19 AM7/9/25
to google-apps-sc...@googlegroups.com
Hi Team,

I am looking for an app script to get a list of users who has existing access to book a meeting room.  

Thanks,
Vinu T

Google Pony

unread,
Jul 10, 2025, 4:02:24 AM7/10/25
to Google Apps Script Community

Dear Vinu T,  


Thank you for your question! Below is a Google Apps Script solution that retrieves a list of users who currently have access to book a specific meeting room (resource calendar).  


Solution: List Users with Access to a Meeting Room  

const listMeetingRoomAccessUsers = () => {
  // Replace with the meeting room's calendar ID (usually the room's email address)
  const meetingRoomCalendarId = 'meeti...@yourdomain.com';

  try {
    // Get the calendar's access control list (ACL)
    const acl = Calendar.Acl.list(meetingRoomCalendarId);

    // Filter and log users with "writer" or "owner" access (can book events)
    const usersWithAccess = acl.items.filter(rule =>
      rule.scope.type === 'user' &&
      (rule.role === 'writer' || rule.role === 'owner')
    ).map(rule => rule.scope.value);

    // Log the results (or return/send via email)
    console.log('Users with booking access:', usersWithAccess);

    // Optional: Send results via email
    MailApp.sendEmail({
      to: Session.getActiveUser().getEmail(),
      subject: 'Meeting Room Access Report',
      body: `Users with access to ${meetingRoomCalendarId}:\n\n${usersWithAccess.join('\n')}`
    });

    return usersWithAccess;
  } catch (error) {
    console.error('Error fetching calendar access:', error);
    return [];
  }
}

Key Notes:  

1. Prerequisites:

 The script requires the Calendar API enabled in the Apps Script project (go to `Resources > Advanced Google Services`).  

 The user running the script must have admin rights or owner access to the meeting room's calendar.  


2. How to Use:

Replace `meeti...@yourdomain.com` with the target meeting room's email/calendar ID.  

The script logs users with "writer" or "owner" roles (these roles can book events). Adjust roles if needed.  


3. Output Options:

 Results are logged to the Apps Script console and optionally emailed.

 You can modify the script to output to a Google Sheet or UI alert.


Let me know if you need further customization (e.g., checking group access, filtering specific roles).


Sincerely yours,
Sandeep Kumar Vollala
Developer - India
LinkedIn Logo WhatsApp Logo
Reply all
Reply to author
Forward
0 new messages