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.
Solved! Go to Solution.
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']
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
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogHello @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']
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
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
64 | |
23 | |
16 | |
15 | |
11 |
User | Count |
---|---|
118 | |
35 | |
30 | |
28 | |
26 |