Copy SharePoint list attachment (s) to a document library using Microsoft Flow
Updated – 20 August 2019:
Since we now have a much easier way to achieve the same results, I have updated this flow (two less actions). Mainly two changes, 1) We do not need to create a text file to create a folder. If we provide the path SharePoint will ensure that folder is created if not already there. 2) ‘Get attachment content’ action is now replaced with ‘Get file content‘ which is bit simpler.
Here are the updated screenshots:
Note the Id obtained from ‘Get attachments’ action.
Compose action with Title/Id from the item created action. You can name anything you want but I combined title with Id this to ensure that the folder created is unique.
Note the folder name, I have the list item with User 3 (Title) and File Size confirms that files are copied correctly.
This one is simple, yet very powerful and was only possible with the power of Microsoft Flow. I did something similar in SharePoint 2010 and it took me at least two days to learn and implement, but with the Flow, I have a working solution ready within 30 mins.
The requirement was, user will submit a form with some attachments and these attachments/ documents will need to be reviewed and processed. Reviewing individual files in the custom list could be very tedious (clicking one by one files) and we also don’t get the same experience as the modern library with preview etc. It also allows the admin staff to share file easily during the review stage if needed. We can also send multiple attachments via email using an Array action.
The Flow will trigger when an item is created in a particular list. The first action would be get the attachments from a particular item submitted.
Next, we will loop through all the content of the attachments of the particular item.
I wanted to create a folder per item with the name of the User Name and ID (in case, there are users with the same name). So we have compose action which gives us a path and in order to create a folder (as there is no create folder action available) we have to create an empty text file. This can be deleted, if required, but I keep this.
Last step is to create the files in the particular folder created above. In my case, I have also decided to copy the files into a different site collection. Yes, a different collection, imagine doing this with the SharePoint Designer!
Let’s run this by adding an item in the list. I have four attachments submitted with this item.
All the attachment submitted were copied in a new folder called User Name – ID (SharePointer-30), I am using a default ID provided by the custom list as it is auto numbered and unique.