cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gvazqu42
New Member

PowerApp wont show Subfolder documents using Not(IsFolder)

I apologize in advance for the long thread, but wanted to explain as much as possible.

 

I'm building a powerapp that should simply read a document library and its subfolders and show the documents in a gallery. The problem I continue to have is that I can't retrieve any documents which are in a sub-folder. I've tested and can easily get the docs in the main library folder path, but not sub folders.  I can also get the subfolders themselves, but again I can't see the documents in any of those subfolders. 

 

I've tried building 2 different apps along with 3 different test libraries and I continue to have the same result, which again is I can retrieve and show sub folders in a gallery, but I CANNOT get and show the documents of any subfolders. I tried this on a brand new test doc library with 2 folders and total of 5 docs, vs a large doc library hundred of docs and the results are the same. 

 

Below are a few solutions I've tried along with variations of the filter formula I'm using against a collection based on the doc library. 

1. I've used the approach of multiple galleries like demonstrated in the following thread. 

https://powerusers.microsoft.com/t5/Building-Power-Apps/How-to-view-subfolders-and-files-within-a-fo...

 

2. I've also tested populating a combo box with names of the folders from the library and then passing those selected.Name to a gallery on combo box select.  

 

Again both of these worked for folders, I was able to retrieve the folders metadata, but not the items in the folders. Below is an example of a formula I'm using for the Items property on the galleries. 

Shared Documents = name of original library(but I've tested multiple libraries)

TestDocs = the collection created from Shared Documents, which has 2 folders(TestFolder1, TestFolder2).

folderGalleryOne and FolderGalleryTwo = example names of galleries used. 

 

Filter(TestDocs,

Not(IsFolder), 

'Folder path' = "Shared Documents/" & folderGalleryOne.Selected.Name & "/") 

 

I've tried variations of this where I've removed the IsFolder portion, where I use && instead of commas. I've also populated doc items with meta data fields to then add to the filter. ex. I add string column named "TestColumn" and populate each document with the text "Presentation". Then add that to the filter, 

 

Filter(TestDocs,

'Folder path' = "Shared Documents/" & folderGalleryOne.Selected.Name & "/") ,

TestColumn = "Presentation").

 

I've tried variations where I use the EndsWith filter

Filter(TestDocs,

'Folder path' = "Shared Documents/" & folderGalleryOne.Selected.Name & "/") ,

EndsWIth('File name with extention', "pdf")) 

 

Nothing seems to work, no matter what I try I can't see the docs in a document library sub folder. I'm hoping this is a simple issue, something minor I'm missing, however if anyone has any recommendations I would greatly appreciate it. 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@gvazqu42 

It is important to know with Document Libraries that there are really no folders in them.  The list is a list.  SharePoint uses calculated columns to simulate the concept of folders and incorporates them into a view that makes you think there are folders.

 

That said - Document libraries are extremely subject to record limits and delegation problems.  For record limits, it is very easy for all of the total documents and folders (they are items too) to exceed the 2000 record limit.

To complicate things further, one generally starts to reach for Delegable functions - like StartsWith - to overcome this limit.  The problem is, most of the columns in the library are calculated by SharePoint.  Columns like Full Path, Folder Path, IsFolder, File Name with Extension, etc. are all calculated and are not Delegable!

 

There are workarounds for this by augmenting the records with delegable columns.  This is usually done through PowerAutomate or a double write to your documents in your app (if you are in fact primarily managing the library only through your app - which is usually not the case with doc libraries.)

 

SO...I mention all of this because it is fairly easy to get this to work on small lists.

Example : Add two Galleries to your screen.  Gallery1 and Gallery2.

Set the Gallery1 Items property to : Filter(yourDocLibrary, IsFolder)  Add a label in the Gallery and set the Text to ThisItem.'Full Path'

Set the Gallery 2 Items property to : Filter(yourDocLibrary, !IsFolder && StartsWith('Full Path', Gallery1.Selected.'Full Path'))  add a label in the Gallery and set the text property to : ThisItem.'File name with extension'

This will give you the ability to select a "folder" and see the files.  You could easily put the Gallery1 Items on a Dropdown and just change the reference in Gallery2 items to your dropdown rather than the Gallery1 (no need to use On Selects, or OnChanges).

 

However, you really need to determine your end goal as it relates to the doc library size including ALL files and folders.  If it is going to exceed the record limit of 2000, then you will have problems that need to be addressed either by reconsidering your design or reconsidering the metadata in the doc library.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

5 REPLIES 5
gvazqu42
New Member

One follow up I was successfully able to achieve a solution on a very small doc library. But it required me to rebuild the library and then rebuild a brand new powerapp. But again when I redirected to the app to the original larger doc library it stopped working. 

 

This leads me to believe that there may be an issue with the document library or potentially the size of the library leading to the issue. But again, this doesn't explain why I can see folders but still not the document items. 

RandyHayes
Super User
Super User

@gvazqu42 

It is important to know with Document Libraries that there are really no folders in them.  The list is a list.  SharePoint uses calculated columns to simulate the concept of folders and incorporates them into a view that makes you think there are folders.

 

That said - Document libraries are extremely subject to record limits and delegation problems.  For record limits, it is very easy for all of the total documents and folders (they are items too) to exceed the 2000 record limit.

To complicate things further, one generally starts to reach for Delegable functions - like StartsWith - to overcome this limit.  The problem is, most of the columns in the library are calculated by SharePoint.  Columns like Full Path, Folder Path, IsFolder, File Name with Extension, etc. are all calculated and are not Delegable!

 

There are workarounds for this by augmenting the records with delegable columns.  This is usually done through PowerAutomate or a double write to your documents in your app (if you are in fact primarily managing the library only through your app - which is usually not the case with doc libraries.)

 

SO...I mention all of this because it is fairly easy to get this to work on small lists.

Example : Add two Galleries to your screen.  Gallery1 and Gallery2.

Set the Gallery1 Items property to : Filter(yourDocLibrary, IsFolder)  Add a label in the Gallery and set the Text to ThisItem.'Full Path'

Set the Gallery 2 Items property to : Filter(yourDocLibrary, !IsFolder && StartsWith('Full Path', Gallery1.Selected.'Full Path'))  add a label in the Gallery and set the text property to : ThisItem.'File name with extension'

This will give you the ability to select a "folder" and see the files.  You could easily put the Gallery1 Items on a Dropdown and just change the reference in Gallery2 items to your dropdown rather than the Gallery1 (no need to use On Selects, or OnChanges).

 

However, you really need to determine your end goal as it relates to the doc library size including ALL files and folders.  If it is going to exceed the record limit of 2000, then you will have problems that need to be addressed either by reconsidering your design or reconsidering the metadata in the doc library.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Thanks for the guidance, one thing I realize just prior to reading your message is that YES this solution is over 2000 items. I immediately realize that might be the issue. 

 

I also started with testing adding delegable columns, I was hoping this would help and has in some portions of the process. I'm going to have to take a step back and think about how I want to approach this process, since the items are over 2k and growing. 

 

Regardless thank you for your guidance, greatly appreciated. 

RandyHayes
Super User
Super User

@gvazqu42 

No problem.  Usually making the Full Path of the items a text column is the biggest bang for the buck.

PowerAutomate can be used to, when an item is created in the list, set a "real" column called something like txtFullPath to the calculated Full Path of the item.  Also, the IsFolder to a real column, is helpful.

Now with that column in place, you can delegate things like StartsWith on that column successfully.

 

Yes, there is some upfront design work needed on the library in order to get it to work properly without the limits causing problems.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Great Ideas, I'll give those a try. 

 

Thanks again for the responses and recommendations! 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,623)