Skip to main content
Community site session details

Community site session details

Session Id : ZCzevNrvy4iVLHeRgIBEIW
Power Automate - Building Flows
Suggested answer

Saving attachment from a MS Form to a specific folder in a document library based on the responses

Like (0) ShareShare
ReportReport
Posted on 27 Nov 2024 15:59:47 by 38
Hello Everyone, 
 
I'm looking to save the attachment from an MS Form to specific folders in document library based on the responses received to questions on the form. 
 
For example: If the name entered on the form is "James Smith", I want the attachment from that form to be saved in the folder titled "James Smith" in the document library and in none of the other folders that exist in that library. 
 
I've tried my best to find a solution in Power Automate, but I haven't had any luck. 
 
Thank you in advance!
  • CU29101523-0 Profile Picture
    38 on 03 Dec 2024 at 14:36:25
    Saving attachment from a MS Form to a specific folder in a document library based on the responses
     
    Thank you for the super quick response. The file that is being uploaded/attached to the form is a PDF. 
  • Pstork1 Profile Picture
    67,342 Most Valuable Professional on 03 Dec 2024 at 14:19:56
    Saving attachment from a MS Form to a specific folder in a document library based on the responses
    Is the file that is uploaded to the form a PDF? If its not then you can't just save it as a pdf by changing the file extension. You would need to get the file content and use an action to convert it to a PDF. The ability to do that is dependent on the type of file that is being uploaded.  What kind of file is being attached to the form at this point?
     
    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • CU29101523-0 Profile Picture
    38 on 03 Dec 2024 at 14:05:48
    Saving attachment from a MS Form to a specific folder in a document library based on the responses
    Hi @Pstork1
     
    My apologies for bothering you so much. I have tried to make the flow work appropriately, however, I'm still having trouble getting the file to save as a PDF, instead of an inaccessible file, in the SharePoint document library. 
     
    Here is how I have set up the flow: 
     
     
       
     
    I have tried to add "Parse Json" and "Get File content" to the flow, however it hasn't worked successfully. I'm also not sure if I'm, perhaps, placing these steps in the wrong spot. 
     
    Thank you so much in advance! I really appreciate it. 
     
  • CU29101523-0 Profile Picture
    38 on 28 Nov 2024 at 21:07:51
    Saving attachment from a MS Form to a specific folder in a document library based on the responses
    Hi @Pstork1​​​​​​​

    I can confirm that the file that they are uploading to the MS Form is already a PDF. 
     
    With regards to having the correct extension, how would I go about checking that?
     
    Thank you so much!
  • Suggested answer
    Pstork1 Profile Picture
    67,342 Most Valuable Professional on 28 Nov 2024 at 19:39:28
    Saving attachment from a MS Form to a specific folder in a document library based on the responses
    First, make sure the name you are supplying in the Create file action has an extension that is correct.  It should be there when the user uploads the file.
     
    Second, what kind of file are they uploading? If its not already a PDF you would need to convert it to a PDF. There's an action for that for some of the file types.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog

  • CU29101523-0 Profile Picture
    38 on 28 Nov 2024 at 19:21:22
    Saving attachment from a MS Form to a specific folder in a document library based on the responses
    Hi @Pstork1
     
    This worked amazingly - thank you so much for all your help and for taking the time to post your process. I've run into one little hiccup though - the file is saving as a non accessible file type and I was hoping to have it save as a PDF. Would you have any insight into how I could make this work? 
     
    I tried "Add attachments" or "Get Attachments", but they only seem to work for MS Lists and not SharePoint document libraries. 
     
    Thank you so much in advance and my apologies for all the questions. 
     
     
  • Suggested answer
    Pstork1 Profile Picture
    67,342 Most Valuable Professional on 28 Nov 2024 at 15:31:56
    Saving attachment from a MS Form to a specific folder in a document library based on the responses
    Here are screenshots of a working prototype.  I built a form with three questions. 
    1) Email Address
    2) Filename
    3) File Upload
     
    Then created the following flow that triggers when a Form is submitted.
    Use the List Folder Action to retrieve a list of files and folders in the target folder
    Then use filter array actions to filter the list down to folders only and then to the folder where the folder name in lowercase matches the email address from the form question 1 in lowercase. The match has to be identical. That is why I went with email address rather than a name.
    Finally I used a Create file action to create the file from the form in the folder found in the second filter array.
    The one tricky spot is the last step. The second filter array will output an array with one item in it. If you use that directly it will create an apply to each loop. So I used First() to get the first record from the array and then added the Path field to the end.  YOu can see the code I used in the note.
     
    I hope this helps. The advantage here is that it will work with any number of folders as long as the values match exactly. Using Switches or Conditions to find the right folder will get very complex as the number of potential folders increases.
  • Suggested answer
    xanddix Profile Picture
    17 on 28 Nov 2024 at 01:41:25
    Saving attachment from a MS Form to a specific folder in a document library based on the responses
    Its simple, lets assume that you working on a flow that was 3 differente persons:: James smith, John snow and Jon jones. You just have to create 3 different conditions. In each condition you basicly have to create a html from the responses and tranform into a pdf(assuming that u want the responses in pdf) and then u just have to sent to the respective folder. I saying this if we talking in just a couple names, if there are more than 5 names i recommend realize the flow into a different way because create so many conditions can more time.
     
    If you want more you can contact me. tks bye
  • CU29101523-0 Profile Picture
    38 on 27 Nov 2024 at 20:59:31
    Saving attachment from a MS Form to a specific folder in a document library based on the responses
    Hi @Pstork1
     
    Thank you so much for the reply. Would you be able to elaborate on how I would go about that? I tried to implement it myself but it isn't working for me. 
     
    Many thanks!!!
  • Suggested answer
    Pstork1 Profile Picture
    67,342 Most Valuable Professional on 27 Nov 2024 at 16:31:46
    Saving attachment from a MS Form to a specific folder in a document library based on the responses
    Assuming the response in the Form matches the name of the folder exactly you could use a List Files action to get all the files and Folders in the parent folder (or List Root Folder if the folders are first level). Then use a filter array to get just the list of Folders.  Then you can match the Folder name to the entry from the form. That will give you the path where you need to store the file.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2