Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

How to get the file name of attachments from a SharePoint List?

(0) ShareShare
ReportReport
Posted on by 53

Hello, I'm attempting to build a Power Automate Flow that can grab the filename from each row and put them into a CSV file with two columns:

idfilename
1first.pdf
2second.pdf
3third.pdf

 

that way, I can pre-append my SharePoint's site URL to each id and image to return a link that we be later used in Power BI. However, I am running into some limitations of Power Automate that I do not know how to get around.

 

Currently, I have a flow that will get me all of my items and put them into a CSV file but I only have the option to see if there are attachments, not get the file name at all:

christianunr_1-1708711657965.png

I tried to setup a different flow to get the attachments but that doesn't seem to work for me as I cannot select the ID with Dynamic Content:

christianunr_2-1708711785816.png

I'm not sure where to go at this point. Any help is appreciated.

  • christian-unr Profile Picture
    53 on at
    Re: How to get the file name of attachments from a SharePoint List?

    @Nived_Nambiar - hey, thanks a lot. I tested this and this looks good and returned a csv file for me. However, one issue I just ran into is that it's taking a long time to complete. I have about ~2000 items in the SharePoint list and when I turned on Pagination with 5000 limit threshold, it was around 17 minutes before I cancelled it as that is already too long with ~2000 items.

    Do you know why it is taking so long or if it's possible to speed this up at all? In the first test, it took 48 seconds to get 100 records built which about 2 seconds per record. With ~2000 records X 2 seconds I am looking at ~66 minutes for this to finish.

     

    EDIT: I think I can work around this and just order in descending order to get the newest 100 records and do some joining/refinements with Python.

  • Verified answer
    Nived_Nambiar Profile Picture
    17,741 Super User 2025 Season 1 on at
    Re: How to get the file name of attachments from a SharePoint List?

    Hi @christian-unr 

     

    Try this approach 

     

    1. use get items to get all items from SharePoint list

    Nived_Nambiar_0-1708713576883.png

     

    2. use initialize variable to initialize an array 

    Nived_Nambiar_1-1708713600281.png

     

    3. use apply to each to loop through value dynamic content of get items action

     

    3.1 - use get attachments under apply to each loop to get list of attachments associated with the list item 

    Nived_Nambiar_2-1708713703355.png

     

    3.2- use append to array variable to append ID and filename information as an object to array variable created at step 2.

    Nived_Nambiar_3-1708713770493.png

     

    Nived_Nambiar_4-1708713792150.png

     

    Expression:-  first(outputs('Get_attachments')?['body'])?['DisplayName']

     

    Outside the loop do the below steps 

     

    4. use create csv table to create csv table out of the array variable 

    Nived_Nambiar_5-1708713844201.png

     

    This is how you can create csv table out of sharepoint list with details like ID and filename

     

    Results of the flow

    Nived_Nambiar_6-1708713911070.png

     

     

    Hope this helps !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492