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

%3CLINGO-SUB%20id%3D%22lingo-sub-118968%22%20slang%3D%22en-US%22%3ERest%20property%20to%20see%20if%20any%20items%20in%20folder%20have%20unique%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-118968%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI'm%20looking%20for%26nbsp%3B%20the%20property%20on%20a%20list%20or%20folder%20that%20says%20if%20any%20children%20have%20broken%20inheritance%20(i.e.%20if%20any%20child%20items%20have%20unique%20permissions).%20I%20know%20I%20can%26nbsp%3B%20do%20a%20separate%20query%20to%20find%20all%20item%20in%20a%20folder%26nbsp%3B%20where%20HasUniquePermissions%20eq%20true%2C%20but%20I%20want%20to%20avoid%20the%20extra%20call.%20I%20thought%20there%20was%20a%20property%20on%20the%20parent%20folder%20that%20tells%20whether%20any%20children%20have%20broken%20inheritance%2C%20but%20I%20cant%20seem%20to%20find%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-119359%22%20slang%3D%22en-US%22%3ERe%3A%20Rest%20property%20to%20see%20if%20any%20items%20in%20folder%20have%20unique%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-119359%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Russell%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20far%20as%20I%20know%2C%26nbsp%3Bthere%20is%20no%20such%20a%20property.%3C%2FP%3E%3CP%3EIf%20your%20folder%20structure%20is%20predictable%20some%20%3CSPAN%20class%3D%22gt-card-ttl-txt%22%3Esubsidiary%3C%2FSPAN%3E%26nbsp%3Bobjects'%20properties%20can%20be%20expanded.%20Here%20is%20the%20sample%20in%20PnP%20JS%20Core%20(as%20I%20can%20recall%20you%20use%20the%20lib)%20which%20represents%20the%20idea%3A%3C%2FP%3E%3CDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CPRE%3Epnp.sp.web.getFolderByServerRelativeUrl(%60%24%7B_spPageContextInfo.webServerRelativeUrl%7D%2FShared%2520Documents%60)%0A%20%20.folders%0A%20%20.select('Name%2CServerRelativeUrl%2CItemCount%2CFolders%2FListItemAllFields%2FHasUniqueRoleAssignments%2CFiles%2FListItemAllFields%2FHasUniqueRoleAssignments')%0A%20%20.expand('Folders%2FListItemAllFields%2FHasUniqueRoleAssignments%2CFiles%2FListItemAllFields%2FHasUniqueRoleAssignments')%0A%20%20.get()%0A%20%20.then(results%20%3D%26gt%3B%20%7B%0A%20%20%20%20return%20results.map(result%20%3D%26gt%3B%20%7B%0A%20%20%20%20%20%20return%20%7B%0A%20%20%20%20%20%20%20%20...result%2C%0A%20%20%20%20%20%20%20%20HasUniqueRoleAssignmentsForFolders%3A%20result.Folders.results.filter(folder%20%3D%26gt%3B%20%7B%0A%20%20%20%20%20%20%20%20%20%20return%20folder.ListItemAllFields.HasUniqueRoleAssignments%3B%0A%20%20%20%20%20%20%20%20%7D).length%20%26gt%3B%200%2C%0A%20%20%20%20%20%20%20%20HasUniqueRoleAssignmentsForFiles%3A%20result.Files.results.filter(file%20%3D%26gt%3B%20%7B%0A%20%20%20%20%20%20%20%20%20%20return%20file.ListItemAllFields.HasUniqueRoleAssignments%3B%0A%20%20%20%20%20%20%20%20%7D).length%20%26gt%3B%200%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D)%3B%0A%20%20%7D)%0A%20%20.then(results%20%3D%26gt%3B%20%7B%0A%20%20%20%20console.log(results)%3B%0A%20%20%7D)%0A%20%20.catch(console.log)%3B%3C%2FPRE%3E%3C%2FDIV%3E%3CDIV%3EMaybe%20this%20can%20be%20helpful%20in%20some%20way.%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3ECheers%2C%3C%2FDIV%3E%3CDIV%3EAndrew%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-119087%22%20slang%3D%22en-US%22%3ERe%3A%20Rest%20property%20to%20see%20if%20any%20items%20in%20folder%20have%20unique%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-119087%22%20slang%3D%22en-US%22%3E%3CP%3Emaybe%20this%20link%20can%20help%20you%20with%20your%20search%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.codeproject.com%2FArticles%2F678653%2FHow-to-check-user-permission-for-the-web-list-or-S%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.codeproject.com%2FArticles%2F678653%2FHow-to-check-user-permission-for-the-web-list-or-S%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
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