cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
TimoPertila
Level: Powered On

Creating array of attachments for apporval email

Hi,

 

I am trying to 

1) get n attachments from sharepoint list item (fine)

2) put them all as attachments in single approval mail.

 

What is easiest way to do that? Build array of attachments? How? What kind of array?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Creating array of attachments for apporval email

Hi @TimoPertila,

 

I will offer a simple walkthrough, this might not be the best way, but it works.

Please follow the steps below:
1. Add the SharePoint->Get Items Action, specify the Site Address, and the list name,

2. Initialize two variables, One named to SingleRecord, anothere Named to ListAttachments, both configured to Array type, and leave the Value blank,

50.PNG

3. Add SharePoint->Get attachments action, specify the Site Address, List Name,  then choose the Item ID from the Get items Action, this would Add an Apply to Each automatically,

4. Add another SharePoint->Get Attachment content Action, Specify the Site Address, List Name, Item ID, then choose the File Identifier from the Get Attachments action,

53.PNG

5. Add Data operations-Select Action, choose the Get Attachments Body as the From input, then follow the image below to configrue the Map, Name: Choose the DisplayName from the Get Attachments Action, and the expression for Contentbytes is as below:

body('Get_attachment_content')?['$content']

This formula is used to get the contentBytes value from the SharePoint->Get Attachment content Action,

54.PNG

 

6. Add a Set Variable Action, Name choose to Single Record, Value set to the following expression, this formula is used to generate single record Array of the Attachment from SharePoint,

createarray(first(body('Select')))

55.PNG

 

7. Add a Compose Action, Value choose to Variable- ListAttachments,

8.Add another Set Variable (Set Variable 2), which is used to generate the whole Attachments, Name choose to ListAttachments, Value set to the following expression:

union(variables('SingleRecord'),outputs('Compose'))

56.PNG

 

9.After that, Outside the nested Apply to each, add a Send an Approval Email, Switch the Attachments as Array input, then choose the ListAttachments as the value input:

57.PNG

 

The running results:
58.PNG59.PNG

 

Regards,

Michael

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
7 REPLIES 7
Community Support Team
Community Support Team

Re: Creating array of attachments for apporval email

Hi @TimoPertila,

 

I will offer a simple walkthrough, this might not be the best way, but it works.

Please follow the steps below:
1. Add the SharePoint->Get Items Action, specify the Site Address, and the list name,

2. Initialize two variables, One named to SingleRecord, anothere Named to ListAttachments, both configured to Array type, and leave the Value blank,

50.PNG

3. Add SharePoint->Get attachments action, specify the Site Address, List Name,  then choose the Item ID from the Get items Action, this would Add an Apply to Each automatically,

4. Add another SharePoint->Get Attachment content Action, Specify the Site Address, List Name, Item ID, then choose the File Identifier from the Get Attachments action,

53.PNG

5. Add Data operations-Select Action, choose the Get Attachments Body as the From input, then follow the image below to configrue the Map, Name: Choose the DisplayName from the Get Attachments Action, and the expression for Contentbytes is as below:

body('Get_attachment_content')?['$content']

This formula is used to get the contentBytes value from the SharePoint->Get Attachment content Action,

54.PNG

 

6. Add a Set Variable Action, Name choose to Single Record, Value set to the following expression, this formula is used to generate single record Array of the Attachment from SharePoint,

createarray(first(body('Select')))

55.PNG

 

7. Add a Compose Action, Value choose to Variable- ListAttachments,

8.Add another Set Variable (Set Variable 2), which is used to generate the whole Attachments, Name choose to ListAttachments, Value set to the following expression:

union(variables('SingleRecord'),outputs('Compose'))

56.PNG

 

9.After that, Outside the nested Apply to each, add a Send an Approval Email, Switch the Attachments as Array input, then choose the ListAttachments as the value input:

57.PNG

 

The running results:
58.PNG59.PNG

 

Regards,

Michael

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
TPertila
Level: Powered On

Re: Creating array of attachments for apporval email

Superb, thanks!!

Community Support Team
Community Support Team

Re: Creating array of attachments for apporval email

Hi @TimoPertila,

 

What is your current situation?

If the steps I offered works, then please accept it as the solution.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Re: Creating array of attachments for apporval email

Hi Micheal,

 

Excellent post but i am stuck here as the solution would run through all the list items as soon as I try to bring in dynamic content into the body of the message or subject where Flow would force an apply a 3rd Apply to each with the following message:

 

"Based on the output parameters you selected, we've added a for each container for you. For each enables you to perform actions for each individual item in a set of values"

 

If I stick to static message body, subject etc and just add the attachment array this works correctly. Could you please provide a solution?

 

Regards

Shaheen

 

 

Anonymous
Not applicable

Re: Creating array of attachments for apporval email

Hi,

 

 

 

 

body('Get_items')?['Value']?[0]?['CustomerContact']

image.png

 

The issue I face now is that I am seeing some other values of the same column being returned from the array instead of the specific item where the I had run the flow (for eg Expected result would have been John Ingram but instead I get Kelly P which is another sharepoint item)

 

Any help on this would be appreciated as the original solution on this works correctly and the current challenge I am facing is when I am trying to put in the values from different columns into the message body without creating a new "Apply to Each" loop as mentioned in my previous post.

 

@v-micsh-msft 

 

Regards

Shaheen

Anonymous
Not applicable

Re: Creating array of attachments for apporval email

Solved the issue by adding another Get Item (Not Items) before the send Email and used the dynamic variables from the new Get Item (phew). Doing this way prevented the creation of the third apply to each Smiley Happy

 

Thanks for anyone who would have tried to find a solution.

 

image.png

bamboogi
Level: Power Up

Re: Creating array of attachments for apporval email

Hi

 

Thanks very much for your reply, it exactly what I am looking for. 

 

A question though, in my application I would like to have all the attachments for a particular item attached to the email. At the moment, I get all attachments for the whole list rather an individual item (via ListAttachment) . I have tried using the SingleRecord variable as the attachment but this limits to one attachment only. 

 

Any help you could provide would be appriciated.

Helpful resources

Announcements
firstImage

Microsoft Flow Online Conference

Join us for a FULL day of FREE Microsoft Flow Sessions from some of the best minds in the industry!

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

thirdImage

New Flow Community Board!

Check out the new Microsoft Flow Community Blog Topic Suggestion board!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 39 members 4,137 guests
Please welcome our newest community members: