Google Apps Script

Class DomainGroup

A Google Apps Domain group.

Only Google Apps Domain administrators are allowed to use this class.

Methods

MethodReturn typeBrief description
addMember(memberId)DomainGroupAdds a member to the group.
addOwner(ownerId)DomainGroupAdds an owner to the group.
deleteGroup()voidDeletes the group.
getAllMembers()String[]Gets the list of members for the group.
getAllOwners()String[]Gets the list of owners for the group.
getDescription()StringGets the description of the group.
getId()StringGets the group identifier.
getName()StringGets the name of the group.
getPermissionLevel()PermissionLevelGets the permission level of the group.
removeMember(memberId)DomainGroupRemoves a member from the group.
removeOwner(ownerId)DomainGroupRemoves an owner from the group.
setDescription(description)DomainGroupSets the description of the group.
setName(name)DomainGroupSets the name of the group.
setPermissionLevel(level)DomainGroupSets the permission level of the group.

Detailed documentation

addMember(memberId)

Adds a member to the group. A member can be specified as a user's email address or the email address of another group.

 
// Adds a member with email "nick@example.com" to the group.
 var group = GroupsManager.getGroup("testgroup").addMember("nick@example.com");
 

Parameters

NameTypeDescription
memberIdStringthe email address of the user or group to be added to the group

Return

DomainGroup — the updated group


addOwner(ownerId)

Adds an owner to the group.

 
// Adds nick@example.com as an owner to the group.
 var group = GroupsManager.getGroup("testgroup").addOwner("nick@example.com");
 

Parameters

NameTypeDescription
ownerIdStringthe email address of the user or group to be added to the group

Return

DomainGroup — the updated group


deleteGroup()

Deletes the group.

 
// Deletes the group named "testgroup".
 var group = GroupsManager.getGroup("testgroup");
 group.deleteGroup();
 

getAllMembers()

Gets the list of members for the group.

 
// Logs all of the members of group "testgroup".
 var group = GroupsManager.getGroup("testgroup");
 var members = group.getAllMembers();
 Logger.log(members);
 

Return

String[] — an array of Strings representing the email addresses of all the group members


getAllOwners()

Gets the list of owners for the group.

 
// Logs all of the owners of the group.
 var group = GroupsManager.getGroup("testgroup");
 var members = group.getAllOwners();
 Logger.log(members);
 

Return

String[] — an array of Strings representing the email addresses of all the group owners


getDescription()

Gets the description of the group.

 
var group = GroupsManager.getGroup("testgroup");
 var description = group.getDescription();
 

Return

String — the description of the group


getId()

Gets the group identifier.

 
// Logs the ID's of all groups in the domain.
 var groups = GroupsManager.getAllGroups();
 for (var i in groups) {
   var group = groups[i];
   Logger.log(i + ": " + group.getId());
 }
 

Return

String — the group identifier


getName()

Gets the name of the group.

 
var group = GroupsManager.getGroup("testgroup");
 var name = group.getName();
 

Return

String — the name of the group


getPermissionLevel()

Gets the permission level of the group.

 
// Gets the group's permission level.
 var group = GroupsManager.getGroup("testgroup");
 var permission = group.getPermissionLevel();
 

Return

PermissionLevel — the permission level of the group


removeMember(memberId)

Removes a member from the group. A member can be specified as a user's email address or the email address of another group.

 
// Removes a member with email "nick@example.com" from the group. 
 var group = GroupsManager.getGroup("testgroup").removeMember("nick@example.com");
 

Parameters

NameTypeDescription
memberIdStringthe email address of the user or group to be removed from the group

Return

DomainGroup — the updated group


removeOwner(ownerId)

Removes an owner from the group.

 
// Removes nick@example.com from the list of the group's owners.
 var group = GroupsManager.getGroup("testgroup").removeOwner("nick@example.com");
 

Parameters

NameTypeDescription
ownerIdStringthe email address of the user or group to be removed from the group

Return

DomainGroup — the updated group


setDescription(description)

Sets the description of the group.

 
// Changes the description of "testgroup" to "new description".
 var group = GroupsManager.getGroup("testgroup").setDescription("new description");
 

Parameters

NameTypeDescription
descriptionStringthe new description for the group

Return

DomainGroup — the updated group


setName(name)

Sets the name of the group.

 
// Gets a group named "testgroup" and changes its name to "new group".
 var group = GroupsManager.getGroup("testgroup").setName("new group");
 

Parameters

NameTypeDescription
nameStringthe new name for the group

Return

DomainGroup — the updated group


setPermissionLevel(level)

Sets the permission level of the group.

 
// Sets the group's permission level so anyone can post messages to the group.
 var group = GroupsManager.getGroup("testgroup").setPermissionLevel(PermissionLevel.ANYONE);
 

Parameters

NameTypeDescription
levelPermissionLevelthe new permission level for the group

Return

DomainGroup — the updated group

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.