Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Get all Web Groups using JavaScript API in SharePoint 2010

$
0
0

Using SP 2010;

Just for your reference, the following code is to get all the groups that are added at Web/subsite level using SOM

using (SPSite site = new SPSite("http://server/sites/sitecollection/"))
{
    using (SPWeb web = site.OpenWeb("test"))
    {
        foreach (SPRoleAssignment roleAssignment in web.RoleAssignments)
        {
            if (roleAssignment.Member is SPGroup)
            {
                Console.WriteLine("Group: " + roleAssignment.Member.Name);
                }
            }
        }
    }

How to get the same using JavaScript API (SP.js)? Following line of code works, but only in SP 2013.

clientContext.get_web().get_roleAssignments().get_groups();
Following line of code is getting the groups from root level site as well. The subsites has got unique permission and does not inherit permission.
clientContext.get_web().get_siteGroups();
Any help greatly appreciated.


--Cheers


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>