1

I am trying to get a particular folder using JSOM, in order to set group permissions. There is group called NewGroup which should assigned to a folder called NewFolder in the Document Library called Shared Documents.

var clientContext = new SP.ClientContext.get_current();
        var oWebsite = clientContext.get_web();

        var collGroup = oWebsite.get_siteGroups();
        var oGroup = collGroup.getByName("NewGroup");

        var role = SP.RoleDefinitionBindingCollection.newObject(clientContext);
        role.add(oWebsite.get_roleDefinitions().getByType(SP.RoleType.contributor));

        var oFolder = oWebsite.getFolderByServerRelativeUrl("/ActivityTracker/Shared%20Documents/NewFolder");
        oFolder.breakRoleInheritance(false, true);
        oFolder.get_roleAssignments().add(oGroup, role)

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

I am unable to get the result using this code. Please correct me where I am wrong.

Priya
  • 1,359
  • 6
  • 21
  • 41

0 Answers0