SP.Group object
Represents a group on a Microsoft SharePoint Foundation website.
Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
var object = new SP.Group()
Members
The Group object has the following members.
Constructor
The Group object has the following constructor.
Constructor |
Description |
---|---|
Initializes a new instance of the SP.Group object. |
Methods
The Group object has the following methods.
Method |
Description |
---|---|
Updates group properties after changes have been made. |
Properties
The Group object has the following properties.
Property |
Description |
---|---|
Gets or sets a value that indicates whether the group members can edit membership in the group. |
|
Gets or sets a value that indicates whether to allow users to request membership in the group and request to leave the group. |
|
Gets or sets a value that indicates whether the request to join or leave the group can be accepted automatically. |
|
Gets a value that indicates whether the current user can edit the membership of the group. |
|
Gets a value that indicates whether the current user can manage the group. |
|
Gets a value that indicates whether the current user can view the membership of the group. |
|
Gets or sets the description of the group. |
|
Gets or sets a value that indicates whether only group members are allowed to view the membership of the group. |
|
Gets or sets the owner of the group which can be a user or another group assigned permissions to control security. |
|
Gets the name for the owner of this group. |
|
Gets or sets the email address to which the requests of the membership are sent. |
|
Gets a collection of user objects that represents all of the users in the group. |
Remarks
Each group contains a collection of users and has a unique identifier.
Example
The following example creates an input button on an application page that adds the current user to the visitors group on the current website.
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">
var user;
var visitorsGroup;
function runCode() {
var clientContext = new SP.ClientContext();
var groupCollection = clientContext.get_web().get_siteGroups();
// Get the visitors group, assuming its ID is 4.
visitorsGroup = groupCollection.getById(4);
user = clientContext.get_web().get_currentUser();
var userCollection = visitorsGroup.get_users();
userCollection.addUser(user);
clientContext.load(user);
clientContext.load(visitorsGroup);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
alert(user.get_title() + " added to group " + visitorsGroup.get_title());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
<input id="Button1" type="button" value="Run Code" onclick="runCode()" />
</asp:Content>
REST resource endpoint
See Group resource for more information.
Endpoint URI structure
http://<sitecollection>/<site>/_api/web/sitegroups(groupid)
HTTP requests
This resource supports the following HTTP commands:
MERGE syntax
MERGE http://<sitecollection>/<site>/_api/web/sitegroups(groupid)
POST syntax
POST http://<sitecollection>/<site>/_api/web/sitegroups(groupid)
PUT syntax
PUT http://<sitecollection>/<site>/_api/web/sitegroups(groupid)