SP.RoleDefinitionCollection Class

SharePoint 2010

Last modified: March 31, 2011

Applies to: SharePoint Foundation 2010

Represents the collection of SP.RoleDefinition Class objects that define the role definitions that are available for use within the Web site.


The following example creates an input button on an application page that defines a new role and adds it to the role definitions collection.

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">

    var roleDefinitionCollection;
    var roleDefinition;
    function runCode() {
        var clientContext = new SP.ClientContext.get_current();
        if (clientContext != undefined && clientContext != null) {
            var web = clientContext.get_web();

            var permissionsManage = new SP.BasePermissions();

            // Specify properties of the role definition.
            var roleCreationInfo = new SP.RoleDefinitionCreationInformation();
            roleCreationInfo.set_description('Role for managing user permissions.');
            roleCreationInfo.set_name('Manage User');

            // Add to the role definitions collection.
            this.roleDefinitionCollection = web.get_roleDefinitions();
            this.roleDefinition = this.roleDefinitionCollection.add(roleCreationInfo);


            clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

    function onQuerySucceeded() {
        alert('Created role: ' + this.roleDefinition.get_name());

    function onQueryFailed(sender, args) {
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());


    <input id="Button1" type="button" value="Run Code" onclick="runCode()" />