Stay organized with collections Save and categorize content based on your preferences.
Groups
This service allows scripts to access Google Groups. It can be used to query information such as a group's email address, or the list of groups in which the user is a direct member. Here's an example that shows how many groups the current user is a member of:
vargroups=GroupsApp.getGroups();Logger.log('You are a member of %s Google Groups.',groups.length);
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-09 UTC."],[[["\u003cp\u003eThe Groups service enables scripts to interact with Google Groups, allowing tasks like retrieving group details and user memberships.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eGroup\u003c/code\u003e class represents a Google Group, providing methods to access its email, members, roles, and child groups.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eGroupsApp\u003c/code\u003e class provides methods for retrieving group information, such as finding a group by email or listing a user's memberships.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eRole\u003c/code\u003e enum defines the possible roles a user can have within a group (e.g., OWNER, MEMBER).\u003c/p\u003e\n"]]],[],null,["Groups\n\nThis service allows scripts to access Google Groups. It can be used to query\ninformation such as a group's email address, or the list of groups in which the\nuser is a direct member. Here's an example that shows how many groups the\ncurrent user is a member of: \n\n var groups = GroupsApp.getGroups();\n Logger.log('You are a member of %s Google Groups.', groups.length);\n\nClasses \n\n| Name | Brief description |\n|-------------------------------------------------------|----------------------------------------------------------------------------------------|\n| [Group](/apps-script/reference/groups/group) | A group object whose members and those members' roles within the group can be queried. |\n| [GroupsApp](/apps-script/reference/groups/groups-app) | This class provides access to Google Groups information. |\n| [Role](/apps-script/reference/groups/role) | Possible roles of a user within a group, such as owner or ordinary member. |\n\n[Group](/apps-script/reference/groups/group) \n\nMethods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------------------------------|------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [getEmail()](/apps-script/reference/groups/group#getEmail()) | `String` | Gets this group's email address. |\n| [getGroups()](/apps-script/reference/groups/group#getGroups()) | [Group[]](/apps-script/reference/groups/group) | Retrieves the direct child groups of the group. |\n| [getRole(email)](/apps-script/reference/groups/group#getRole(String)) | [Role](/apps-script/reference/groups/role) | Retrieves a user's role in the context of the group. |\n| [getRole(user)](/apps-script/reference/groups/group#getRole(User)) | [Role](/apps-script/reference/groups/role) | Retrieves a user's role in the context of the group. |\n| [getRoles(users)](/apps-script/reference/groups/group#getRoles(User)) | [Role[]](/apps-script/reference/groups/role) | Retrieves users' roles in the context of the group. |\n| [getUsers()](/apps-script/reference/groups/group#getUsers()) | [User[]](../base/user.html) | Gets the direct members and banned members of the group that have a known corresponding Google account. |\n| [hasGroup(group)](/apps-script/reference/groups/group#hasGroup(Group)) | `Boolean` | Tests if a group is a direct member of this group. |\n| [hasGroup(email)](/apps-script/reference/groups/group#hasGroup(String)) | `Boolean` | Tests if a group is a direct member of this group. |\n| [hasUser(email)](/apps-script/reference/groups/group#hasUser(String)) | `Boolean` | Tests if a user is a direct member of the group. |\n| [hasUser(user)](/apps-script/reference/groups/group#hasUser(User)) | `Boolean` | Tests if a user is a direct member of the group. |\n\n[GroupsApp](/apps-script/reference/groups/groups-app) \n\nProperties\n\n| Property | Type | Description |\n|----------|--------------------------------------------|-------------|\n| `Role` | [Role](/apps-script/reference/groups/role) | |\n\nMethods\n\n| Method | Return type | Brief description |\n|--------------------------------------------------------------------------------------------|------------------------------------------------|----------------------------------------------------------------------------------|\n| [getGroupByEmail(email)](/apps-script/reference/groups/groups-app#getGroupByEmail(String)) | [Group](/apps-script/reference/groups/group) | Retrieves the group having the specified email address. |\n| [getGroups()](/apps-script/reference/groups/groups-app#getGroups()) | [Group[]](/apps-script/reference/groups/group) | Retrieves all the groups of which you are a direct member (or a pending member). |\n\n[Role](/apps-script/reference/groups/role) \n\nProperties\n\n| Property | Type | Description |\n|-----------|--------|------------------------------------------------------------------------------------------------------------------------------|\n| `OWNER` | `Enum` | The owner of a group. |\n| `MANAGER` | `Enum` | The manager of a group. |\n| `MEMBER` | `Enum` | A user who is a member of this group but is neither an owner nor a manager. |\n| `INVITED` | `Enum` | A user who has been invited to join a group by an owner or manager of the group but who has not yet accepted the invitation. |\n| `PENDING` | `Enum` | A user who has requested to join a group but who has not yet been approved by an owner or manager. |\n| `BANNED` | `Enum` | A user who has been banned from a group and cannot attempt to join it. |"]]