cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Luka84
Advocate III
Advocate III

Access SharePoint Document Library Folder Contents in PowerApps

Good day,

I hope everyone is well and safe with your families and loved ones!

 

Need some advice please, been going at this thing for 24 hours now without any success

Basically, I'm building a Digital Archive on a SharePoint Library and using PowerApps as an interface (To support staff working from home); in details I have a SharePoint Document Library (7,000 Folders and about 18,000 files) in a Gallery in PowerApps, showing only folder names without contents.

 

What I want to achieve is the following:

When I click on a folder, I would like to see it's contents (Can't use 'Folder Path' or anything else due to Delegation issues).

I thought the best way is to fetch the folder contents from SharePoint using Flow, and saving them to a gallery - but I don't have any experience with JSON and have no idea how to do this correctly.

I don't know whether to use "GET FILES" or "LIST FOLDER" or "SEND AN HTTP REQUEST" - honestly they all confuse me lol

 

Below is the full Process I would like to Implement - for reference:

- Create a new folder in a SharePoint Library from Powerapps (DONE)

- Add Folder/File properties from Powerapps (DONE)

- Attach new files to SharePoint Library from PowerApps (IN PROGRESS)

- See all the Document Library Folders (DONE)

- Access the folder contents once a user select a folder (All the files listed within the selected folder) (STUCK HERE)

- Display all the columns that describe the file in the SharePoint Document Library (I suppose it's called File Properties or Metadata) (STUCK HERE)

- Be able to update the File Columns/Properties when needed (Such as change the status) (I THINK I KNOW HOW TO DO THIS)

 

I've read over 50 articles and support tickets but still struggling with this thing

Thanks in advance - any help will be truly appreciated

3 ACCEPTED SOLUTIONS

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

I'll try to get this all written up in a few days to clarify it more, but here are the basics of the flow you call to get and return the list of files and folders in a folder. Explanation below

screenshot.png

1. The flow is kicked off using a button (or the selector in a gallery that lists all the folders in the root of the library). It passes the name of the selected folder as a parameter.

2. The flow takes the folder name, precedes it with %252fShared%2bDocuments%252f (this is name of the library /Shared Documents/, but to get the files or folders you need to encode spaces and slashes)

3. The actual folder name is also encoded to replace any spaces in the name using this formula:

replace(triggerBody()['GetFolder_Value'],' ','%2b')
4. A list folder action gets the list of files from the encoded folder name
5. A select action lets us pick the metadata fields we want to return to Power Apps.  Returning everything would be inefficient.  My demo only returns three fields, but you can easily map more.
6. A response statement returns the output of the select statement as a JSON array. Run it once to get output in the select and use that to generate the JSON schema for the Response.
7. Have Power Apps take the response output and store it in a Gallery.  Filtering the Gallery on isFolder=true will give you a list of folders in that parent folder, isFolder=false will give you the list of files.
 
Hope that points you in the right direction.


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Pstork1
Dual Super User III
Dual Super User III

Yes, that is also possible.  To do that use Get File (Properties Only) instead of List Folder.  Some of the values will also need adjusting.  But then you should have access to all the properties or specifically the properties in a particular view.  Here's a screenshot of doing that.

 

screenshot.png

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Hi again,
Thanks for not forgeting about me. I found another way to doing this actually after giving up on the flow.
Basically i added 2 columns in the library, firsr column is called "Folder" and will have either a "yes" or "no" added at the time when the folder or file is added from powerapps, and another column that contains the name of the folder for filtering, added only when a file is created using powerapps.

I then create 2 galleries in powerapps, one to show folders using the "startswith" for filtering and add the startswith(folder, "yes"), which shows me all the folders.
For the files gallery, i just add 2 startswith functions for the filter:
- startswith(folder, "no"), startswith(foldername, gallery.selected.foldername)

And boom, i have the files in that folder without any calls to flow or any limits (since startswith is completely delegable using text columns)

Hope this can help someone, and thank u so much for your advice, definitely learnt a few things these couple of days

Regards
Luka

View solution in original post

20 REPLIES 20
Luka84
Advocate III
Advocate III

@Pstork1 Bumping 😃

Pstork1
Dual Super User III
Dual Super User III

Let me see if I can put a POC together and give you the steps.  I think what you will be looking for involves the SharePoint list Folder action in Flow.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

That's Correct.

Apologies for the trouble, I hope it doesn't take much of your time

I literally gave up after so much research, below is one of the most useful articles i've found but still haven't figured out how to go to the correct folder under the "list folder" flow, and how to send the folder contents back to PowerApps:

https://mydevexperience.wordpress.com/2019/10/12/microsoft-flow-retrieve-all-files-from-sharepoint-l...

 

once again, thank you so much, I hope your effort will prove useful to other users in the future

Pstork1
Dual Super User III
Dual Super User III

I'll try to get this all written up in a few days to clarify it more, but here are the basics of the flow you call to get and return the list of files and folders in a folder. Explanation below

screenshot.png

1. The flow is kicked off using a button (or the selector in a gallery that lists all the folders in the root of the library). It passes the name of the selected folder as a parameter.

2. The flow takes the folder name, precedes it with %252fShared%2bDocuments%252f (this is name of the library /Shared Documents/, but to get the files or folders you need to encode spaces and slashes)

3. The actual folder name is also encoded to replace any spaces in the name using this formula:

replace(triggerBody()['GetFolder_Value'],' ','%2b')
4. A list folder action gets the list of files from the encoded folder name
5. A select action lets us pick the metadata fields we want to return to Power Apps.  Returning everything would be inefficient.  My demo only returns three fields, but you can easily map more.
6. A response statement returns the output of the select statement as a JSON array. Run it once to get output in the select and use that to generate the JSON schema for the Response.
7. Have Power Apps take the response output and store it in a Gallery.  Filtering the Gallery on isFolder=true will give you a list of folders in that parent folder, isFolder=false will give you the list of files.
 
Hope that points you in the right direction.


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

This is excellent, i will try it out this evening and get back with results.
Thank you once again for your help

Hi @Pstork1 

Let me start by saying THANK YOU SO MUCH !!

I just got the chance to try this out now, and so far I was able to correctly fetch the files under the "LIST FOLDER" flow

Just wanted to ask, is there a way to fetch the columns of the files as well, since the "SELECT" only allows to fetch Metadata?

Reason being, I want to be able to display some information about the file such as "STATUS", which is a column i added to the library, and allow the user to update it when they're done reviewing it

I can't believe after I almost gave up, there's now big hope in actually getting this project done - Thanks to your guidance and support.

Have a great day ahead

Luka

Pstork1
Dual Super User III
Dual Super User III

Yes, that is also possible.  To do that use Get File (Properties Only) instead of List Folder.  Some of the values will also need adjusting.  But then you should have access to all the properties or specifically the properties in a particular view.  Here's a screenshot of doing that.

 

screenshot.png

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Hi @Pstork1 ,

Thanks for the update

I tried the recommended method but I think I'm doing something wrong

Basically, the "LIST FOLDER" fetches all the files within the specified folder correctly

However the "GET FILES (PROPERTIES ONLY)" comes back blank - not sure why

 

Below screenshots for reference:

1. Syntax for GET FILES (PROPERTIES ONLY)

Syntax for Get Files (Properties only)Syntax for Get Files (Properties only)

 

2. Result for GET FILES:

Result for Get FilesResult for Get Files

 

3. Results for LIST FOLDER:

Result for LIST FOLDERResult for LIST FOLDER

 

Thanks in advance (Y)

Pstork1
Dual Super User III
Dual Super User III

Not sure why that is happening.  You might want to try it without the include Nested items.  That may be trying to bring back too much data.  Otherwise, it looks correct to me and it does work on my sample.  BTW, if you do the Get Files (Properties Only) you won't need the List Folder.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,520)