I have a folder in document library and each folder in it has unique permissions.

enter image description here

Now I need to retrieve the permission group names attached to it using javascript only. On click of advanced as given below

enter image description here

We get the groups and users who have permission to the folder.

enter image description here

I need only the SharePoint group names as the output using Javascript.

Can you please help me with this.

Thanks in advance

2 Answers 2


I think you should first get all unique permission for a folder using get_roleAssignments(), then check if the retrieved permission type get_principalType() only equals to SharePoint Group.

Download the JS script from GitHub and check the details at How to Get SharePoint Folder Permissions Using JavaScript filtered by Groups or Users?

  • Hi, Can you please help me with this. My code isn't working with the follwing line. var GetRoles = curruntFolder.get_roleAssignments().getEnumerator(); Till role assignments its working. Then getEnumenrator() the code is stuck there. thanks in advance Feb 15, 2021 at 3:48

You could use jQuery Ajax with REST API to achieve it.

The following code for your reference:

<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {      
    getFoldersRoleAssignments("Documents"); //Enter your Library name
function getFoldersRoleAssignments(listName){

    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/GetFolderByServerRelativeUrl('"+listName+"')/folders?$expand=ListItemAllFields/RoleAssignments/Member";

        url: requestUri,
        type: "GET",
        contentType: "application/json;odata=verbose",
         headers: { "Accept": "application/json;odata=verbose"},
        success: function (data) {
            var html="";
            var folders=data.d.results;
            for(var i=0;i<folders.length;i++){          
                    html+="<b><p>Folder Name: "+folders[i].Name+"</p></b>";
                    var roleAssignments=folders[i].ListItemAllFields.RoleAssignments.results;
                    for(var j=0;j<roleAssignments.length;j++){
        error: function (e) {
            //alert("Failed to get details");                
<div id="foldersPermissions"></div>

enter image description here

  • $("#foldersPermissions").html(html); In this statement where do you declare $("#foldersPermissions") Feb 12, 2021 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.