web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Retrieving individual ...
Power Apps
Answered

Retrieving individual files from SharePoint document library on PowerApps

(0) ShareShare
ReportReport
Posted on by 75

I have a document library that holds html files. Each file is associated to one user. I have an app on power apps that I would like to retrieve individual files associated with the user that is logged into power apps. This user has a file associated to his name in the SharePoint library under "modified by". How can I go about retrieving a file in that document library to showcase on the power apps screen after hitting a button? 

 

I am also getting a delegation issue with this:

'folder path' = "shared doc/testing/"

 

So far I have the following:

Set(currentUser, User());

ClearCollect(userFiles, Filter(mydoc, 'folder path' = "shared doc/testing/",  'Modified By'.DisplayName = currentUser.FullName));

Set(htmlfile, First(userfiles).Name);

 

and then I have the htmltext property to htmlfile.

 

However, I am not displaying anything, it is showing up as blank. It is saying "htmlfile" is blank. 

Am I going about this the wrong way or did i miss a step with the html file.

 

Thanks

Categories:
  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    Hi. @PowerAppsHelpCD ,

    The issue is that setting a file as a Variable does not read the contents of the file. if you have an Image Control with the Image property of

    LookUp(
     mydoc, 
     'folder path' = "shared doc/testing/", 
     'Modified By'.DisplayName = currentUser.FullName
    ).'{Thumbnail}'.Large

    you could view the file, however you might consider constructing a SharePoint List with Multiline Rich Text field containing the HTML text and then you could look it up and display it in you HTML text control.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • PowerAppsHelpCD Profile Picture
    75 on at

    I tried to add an image and placed the code in there, it is giving me the same issue with the delegation warning as well as errors for .'{thumbnail}'.Large

  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    @PowerAppsHelpCD ,

    Firstly, I assumed Delegation was not an issue as you had not mentioned it, however queries on ‘folder path’ are simply not Delegable, so you would need a Text field in there with your path to query in a Delegable manner. You also have a small t in Thumbnail.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • IevaD Profile Picture
    16 on at

    Your button on select property: Set(yourfile,Lookup(mydoc,'Modified by'.DisplayName=CurrentUser.FullName).

    You can use pdf Viewer document property for html file:

    Substitute(
     yourfile.Thumbnail.Small;
     "transform/thumbnail";
     "transform/pdf"
    )

     

  • PowerAppsHelpCD Profile Picture
    75 on at

    How would I go about using a text field in there with my path to query in a delegable manner? Thanks

  • PowerAppsHelpCD Profile Picture
    75 on at

    I wrote the same as you did however I am getting error for invalid number of arguments: received 1, expected 3-4

  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    @PowerAppsHelpCD ,

    You would need to add the field to your Library and then populate it with your Path (or whatever identifier you need). This should be fairly straightforward in Power Automate when you create it initially. The PDF option mentioned by @IevaD should also work but does not address the Delegation issue nor will look any different from displaying the Thumbnail in an Image Control.

  • MarkRahn Profile Picture
    1,424 Super User 2026 Season 2 on at

    Hi @PowerAppsHelpCD ,

     

    @WarrenBelz  and @IevaD  are giving you some great suggestions. I would hit both with a Kudo. 😉

     

    I was playing with you code at the same time.

     

    Set(currentUser, User());
    ClearCollect(userFiles, Filter(mydoc, 'Folder path' = "mydoc/shared doc/testing/", 'Modified By'.DisplayName = currentUser.FullName));
    Set(htmlfile, First(userFiles));

     

    The thing I was lookup up was why weren't you getting any values. Note that the 'Folder path' needs to start with the path to your document library and then your folders.

     

    The above code will load the File with its fields into "htmlfile". You are still unable to access the file contents.

     

    Both @WarrenBelz  and @IevaD  point out ways to view the file using an Image Control or the PDF Viewer control. IF you really needed to return the contents, I think you would have to call a Power Automate Flow passing it the Full Path the the document and return the contents.

     

    @WarrenBelz is right. The query is never going to be able to delegate on the Folder Path because SharePoint can't index it. What he is saying is that you would need to add a text field that is populated with the Folder Path on file creation. This field could then be indexed.

     

    With the code from @IevaD , they are running a version of Power Apps where ";" is the same as ",". You needed to change their code to (using commas):

     

    Substitute(
     htmlfile.Thumbnail.Small,
     "transform/thumbnail",
     "transform/pdf"
    )

     

     

    Finally, the last question to ask is "Why are you trying to do this?" Are you trying to make some sort of File Viewer? If you are looking for something like that, check out this video by Reza Dorrani

    https://www.youtube.com/watch?v=lS5MVCzz2r0 

     

    If anyone has answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up or @WarrenBelz answer or @IevaD  answer.

    Thanks.

    -Mark

  • PowerAppsHelpCD Profile Picture
    75 on at

    Thanks for all the assistance. How would I go about achieving this using power automate?

  • Bartelli Profile Picture
    75 on at

    Hello, I have an easier way to accomplish this.  Try adding a data table into your app. It will prompt you to pick a connector, so select SharePoint, and then the library from the list options that will appear.  You'll be able to select all the various columns from your library. The important one, that will give the user a URL to click (then the file will open). Once you have the table built, filter on the current user within the Items property of the data table.

     

    Please let me know if this helps resolve your issue. 

    Table.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard