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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to get the first a...
Power Automate
Unanswered

How to get the first attachment on a SharePoint list item

(0) ShareShare
ReportReport
Posted on by 17

Dear community,

I am currently working on a flow and need to get the first attachment file out of the multiple files attached to a SharePoint list.

 

My flow is typically like this

Get attachments >>> Get Attachment Content >>> then send email with the attachment content.

 

My flow will run and I will get different emails for every attachment on the list meanwhile I needed the first attachment file and not others.

 

It is frustrating and I need help right now.

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @olacharles 

     

    After the get attachments step you will have a loop which will retrieve all the attachments.  You could use a Do until loop or an IF condition with an incremented counter to stop iterating the next attachment. Inside your Do Until Loop or the IF condition (where counter = 1) do the attachment content extraction action steps.

     

    Thanks

  • Verified answer
    tom_riha Profile Picture
    10,185 Most Valuable Professional on at

    Hello @olacharles ,

    you can use the First() expression to get the 'Id' of the first item in the collection of attachments provided by the 'Get attachments' action. Then apply the 'Get Attachment Content' only on the 'Id' of the first item, without 'Apply to each'. 

    First(outputs('Get_attachments')?['body'])?['Id']

     image.png

  • TheOyinbooke Profile Picture
    17 on at

    Thank you so much @tom_riha . this works perfectly well!

  • SteveCochrane Profile Picture
    219 on at

    Many thanks for this!

        This works well, but what if in the trigger, we wanted an input to select which file we wanted to rename? For example, an input can have "2", and then, instead of "first(outputs...)" to get the first file, it would be "second(outputs...)", or something equivalent? Adding the input and reading it is fine, but would anyone know the syntax to select a specific file? I would prefer not to use an Apply To each loop.

    Thank you, in advance!

     

    Steve in Spain

  • apettit Profile Picture
    245 on at

    Will you please advise... for whatever reason and whatever I try, I can't seem to get this to work?  Thank you so much for considering!

    2023-01-12 15_32_01-Edit your flow _ Power Automate and 9 more pages - Work - Microsoft​ Edge.pngjson from When a new email arrivesjson from When a new email arrives2023-01-12 15_33_18-Run History _ Power Automate and 9 more pages - Work - Microsoft​ Edge.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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard