cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Saya
Frequent Visitor

Get First Attachment in sharepoint list item with multiple attachments

Hello, 

 

How do i get the first attachment from multiple attachments in a flow?

While in Powerapps we use First(ThisItem.Attachments) to get the first attachment on an item in the sharepoint list that has multiple attachments, how do i get the first attachment in flow when i need to send an email with attachment, but only first attachment. So far this is what i have. I get stuck at Get Attachments - Apply to each option. Not sure how to go ahead and pick only the first attachment out of multiple attachments.

Attachment.PNG

 

 
1 ACCEPTED SOLUTION

Accepted Solutions
v-litu-msft
Community Support
Community Support

Hi @Saya,

 

Does the first attachment mean the first attachment in the attachment list or the first attachment added to the attachments in time?

If it is the first attachment in the attachment list, you could use the index to get it, for example:

body('Get_attachments')[0]

Annotation 2020-04-24 132320.png

 

If it is the first attachment added to the attachments in time, there is no way could do it, cause there is no create time property in the attachment.

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
ScottShearer
Super User
Super User

@Saya 

I don't think that you'll be able to rely on the order of the attachments.  You are going to need to loop through all attachments and make a decision based on some other property such as the file name.

Can you provide a little more information on your requirement?

 

 

 

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

Scott
v-litu-msft
Community Support
Community Support

Hi @Saya,

 

Does the first attachment mean the first attachment in the attachment list or the first attachment added to the attachments in time?

If it is the first attachment in the attachment list, you could use the index to get it, for example:

body('Get_attachments')[0]

Annotation 2020-04-24 132320.png

 

If it is the first attachment added to the attachments in time, there is no way could do it, cause there is no create time property in the attachment.

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@ScottShearer 

 

Ok lets say my list will always have at most 3 attachments and I want to have emails sent at different steps in the process that contain Att1, Att2, Att3 individually at the given step. How would I select a given attachment if I know the filename starts with Att1, Att2, or Att3.

 

To be more specific I am trying to partially automate my current purchasing process.

Send RFQ (request for quote) to my vendor Att1-RFQ

Send RFF (request for funding) to my organizations procurement group Att2-RFF

Send INV (invoice) to accounts payable Att3-INV

 

I can send one or all but I am having a hard time being 100% sure only the one I want gets sent not sending all 3 to the different groups.

@E_Lush 

At selected points in your Flow, loop through the attachments and have a condition in the loop that uses a string expression that evaluates the attachment title - you might use indexOf() or conatins().  When doing the evaluation of the attachment name, note that string comparisons are case sensitive - consider using toUpper() or toLower() here.

Give it a try and, if you get stuck, create a new post with screen shots and I'll try to assist.

 

 

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

Scott

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,327)