cancel
Showing results for 
Search instead for 
Did you mean: 
aprildunnam

Moving PowerApps Attachments to a Document Library

 

Hello Flow Community!

 

I'd like to take a moment to introduce myself.  My name is April Dunnam and I am partner and lead developer at a consulting firm in Tulsa, OK.  I come from a SharePoint centric background so I've built a lot of SharePoint Designer Workflows in my day.  

 

One of the newly released features of PowerApps is the ability to add attachments to a SharePoint list item.  This is a great new feature but what if you'd rather have those documents saved in a document library instead of as attachments?  Fortunately there is a way to accomplish this with Flow! 

 

Background

 

Here's a little background on my use case and setup.  I have a SharePoint list to track RFI's (Request for Information).  I have customized this form with PowerApps and have added the ability to upload attachments to the RFI list item.  I have a seperate SharePoint Document Library named Submittals that I want to move those attachments to.  Ideally, I could copy over some metadta from my RFI like the Vendor Name, PO#, WO# and the RFI # to my document in the submittal and surface up those documents in my PowerApp.

 

How To Make it Happen

 

The first thing we've going to do is create a new blank Flow that will be triggered when an item is created in SharePoint.  Next, we will add the "SharePoint - Get Attachments" Action.  Insert the URL where your SharePoint list is and select the list from the dropdown . For the ID, select the ID from the When an item is created context in the Dynamic Content Window.

 

**Note:  The ID doesn't show by default so you may have to click the "Show More" option in the top right hand corner.

 

Screen Shot 2018-04-21 at 12.10.07 PM.png

 

Now that we have this set to trigger when an item is added and we are getting the attachments, the next step is to get the content from the attachments.  We do this by inserting a "SharePoint - Get Attachment Content" Action.  For the ID property you'll use the ID of the "when item is created" trigger.  For the File Identifier property you'll select the ID from the "Get Attachments" action. 

 

You'll notice after you fill out all of the properties for this action, that it automatically wraps the action in an "Apply to Each" function.  So that means for each attachment that it finds in the previous action, it will get the properties for that attachment.  

 

 

FlowAttachmentContentApplyEach.png

 

What We Have So Far:

 

Item Added to SharePoint via PowerApps --> Get all attachments on this item --> Loop through attachments and get attachment properties

 

Next, we need to use the "SharePoint - Create File" Action to add our attachment to the document library.  The FileName is going to be the Display Name from our Get Attachments action.  The File Content will be the Attachment Content property from our Get Attachment Content Action. 

FlowCreateFileFilled.png

 

 Optional Extra Steps

 

We could technically stop here if we wanted as we have accomplished the task of moving the attachments to a library.  However, I want to copy over some of the metadata from my list item to the document including the associated RFI #, Vendor Name, etc.  To do that, we are going to add the "SharePoint - Update File Properties" action.  This will allow us to take metadata from our list and apply it to the document properties in our library.

FlowUpdateFileProperties.png

 

 

 

 

The last optional thing that we can do here is to go back and remove the attachments from our list item so that we don't have duplicate files out there.  To do this, we will add the "SharePoint - Delete Attachments" action.  The ID will be the ID from the Update File Properties action and the File Identifier is the ID from the Get Attachments Action.

FlowDeleteAttachmentID.png

 

 

 

 

That's it!  You now have a Flow that will get all of the attachements from your SharePoint based PowerApp and move those to a document library with metadata and delete the assocaited attachments. 

 

 

 

Comments
I did something similar just with the flow a while back. Great to see a write up.

This is a great write up. I'm looking to do something similar but do a bit of extra stuff to the excel attachment. The user could upload multiple attachments, but I want a hard link to the excel attachment throughout the process. Any advice would be great!

Nice.

This is great, thank you for the write up!

 

Hi @aprildunnam , this was super helpful thank you. I added in a few additional actions to handle multiple-item metadata fields, append them to strings and copy up to the library. This worked great in conjunction with a powerapp form to submit the files as we are able to surface managed metadata as dropdown lists rather than the neolithic term picker you get in SharePoint modern (that all my users despise!).

 

listflow.png

April,

 

I cannot get the Attachment Content option under the "Get Attachments" section. What did I do wrong?

 

That is the only part of this puzzle that I am missing. Thank YouGetAttachmentContent.PNG

Hi @gatafish  - 

 

Looking at your screenshot it appears that your Get Attachment Content Action is not within the Apply to Each.  You need to make sure it's in the Apply to Each of your Get Attachments Body so that it can get the attachment content of each attachment item.

April,

 

That was it. Got the Attachments moving to the desired location not WITH the Metadata.  

 

THANK YOU!!!

 

Gatafish

GATAFISH_Logo_28MAY2019.png

Awesome, glad you got it working!

Anonymous

Congratulations! it seems a very good solution.

I never used Flow to do any of this, I used JavaScript to upload documents to a SP Library.

 

I will try to test you solution and see if the time to perform the actions will not bog down the application.

 

Regards,

Tom

 

 

Anonymous

Perfect tutorial! Thanks a lot! 🙂

 

But one question:


The attachments can be a picture or a pdf. How can I resolve to keep the attachment type?

 

Please help! 🙂

@aprildunnam ,

 

Are you able to Share how you built the Power Apps part of this process.

I am trying to find a way to get documents into a SharePoint Library after approval and I think this will help, but I am NEW to Power Apps, and would like any guidance on how you did that first step.

 

Thank you in advance for your assistance and great post.

Kind regards

Claire

@aprildunnam 

 

How do you manage the version control,
I've rebuilt this flow, but each time I get the file into my location the version always starts at version 1.0 again but if I want to replace the document, I would like the version number to move to the next major version.

 

Any suggestions?

Kind regards

Claire

I am also trying to accomplish something very similar. I have a document library with version control and am building a Power App so the user can update or submit a new document. I added the attachment card to the Power Apps form and would like it to either update or create new. I realize that this will have to be done with a Flow and need assistance.

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/