Rest property to see if any items in folder have unique permissions

Highlighted
Occasional Contributor

Hi,

I'm looking for  the property on a list or folder that says if any children have broken inheritance (i.e. if any child items have unique permissions). I know I can  do a separate query to find all item in a folder  where HasUniquePermissions eq true, but I want to avoid the extra call. I thought there was a property on the parent folder that tells whether any children have broken inheritance, but I cant seem to find it.

 

 

2 Replies
Highlighted
Highlighted

Hi Russell,

 

As far as I know, there is no such a property.

If your folder structure is predictable some subsidiary objects' properties can be expanded. Here is the sample in PnP JS Core (as I can recall you use the lib) which represents the idea:

 
pnp.sp.web.getFolderByServerRelativeUrl(`${_spPageContextInfo.webServerRelativeUrl}/Shared%20Documents`)
  .folders
  .select('Name,ServerRelativeUrl,ItemCount,Folders/ListItemAllFields/HasUniqueRoleAssignments,Files/ListItemAllFields/HasUniqueRoleAssignments')
  .expand('Folders/ListItemAllFields/HasUniqueRoleAssignments,Files/ListItemAllFields/HasUniqueRoleAssignments')
  .get()
  .then(results => {
    return results.map(result => {
      return {
        ...result,
        HasUniqueRoleAssignmentsForFolders: result.Folders.results.filter(folder => {
          return folder.ListItemAllFields.HasUniqueRoleAssignments;
        }).length > 0,
        HasUniqueRoleAssignmentsForFiles: result.Files.results.filter(file => {
          return file.ListItemAllFields.HasUniqueRoleAssignments;
        }).length > 0
      }
    });
  })
  .then(results => {
    console.log(results);
  })
  .catch(console.log);
Maybe this can be helpful in some way.
 
Cheers,
Andrew