web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Trying to build a flow...
Power Automate
Answered

Trying to build a flow that puts attachments into a specific folder based on a list column entry

(0) ShareShare
ReportReport
Posted on by 22

Hi all!

 

I'm trying to build a flow that will allow employees to upload photos to specific SharePoint document libraries based on how they answer a question in a Microsoft Form.

 

The form has:

  • Which event are your photos from (as a choice question)
  • Attachments

 

My current flow:

  • When a new form response is submitted ...
  • It copies the attachments to my OneDrive ...
  • Creates an item in a SharePoint list ...
  • Copies attachments to the SharePoint list.

 

I can't figure out how to then route it to a particular document library based on the answer to the first question (either in the form or in the list). In other words, if someone chooses 2022 Staff Retreat from the choices, I want the attachments to flow to the document library called 2022 Staff Retreat.

 

I'm starting to wonder if this is even possible.

Categories:
I have the same question (0)
  • wskinnermctc Profile Picture
    6,519 Moderator on at

    It is very possible! You can put a Switch control in your flow and have it use the form response. Then for each switch case, just have the response options.

     

    https://www.youtube.com/watch?v=6KokllQUX2I 

    That is a youtube video that shows a Switch control.

     

    If your form question is - Select which event these photos are from:

    • 2022 Fun Time
    • 2022 Christmas
    • 2023 New Years

    Switch ControlSwitch Control

     

    Let me know if this works for you,

  • elizabethharms Profile Picture
    22 on at

    I have high hopes for this @wskinnermctc ! Here's what my flow looks like right now (and so far it works). I'm guessing I'd need to put it after the last item, right? Once I put in the switch, do you know what action I use to copy the files to a document library? I appreciate all of your help! I'm a first-timer.  🙂

     

    elizabethharms_1-1687902435120.png

     

  • Verified answer
    wskinnermctc Profile Picture
    6,519 Moderator on at

    So there isn't going to be a direct action to Copy a file since you are trying to go from OneDrive to SharePoint. You will need to use the SharePoint - Create file action. This is not much different than the SharePoint - Add attachment action.

     

    I can't make a duplicate of your flow without seeing the expanded steps, but it probably isn't necessary. You have done the hard part already. To finally create a file in the SharePoint document library, it is going to work much like how you are adding the attachments to SharePoint.

     

    Switch Create FileSwitch Create File

     

    In my quick example the Switch is using the Choice response from the Form and then it will create a file in the identified folder.

    Yours will probably be slightly different, so instead of a Create File action within each of the Switch Case, you will probably have an Apply to Each within each Case. And within that Apply to Each you will have the Create File action.

    I'm guessing you could use the same "Add attachment to SharePoint list" step within each Switch case, but replace it with the action Create file.

    You could put the Switch inside of an Apply to Each, but I think it looks cleaner to have it outside and then the individual Apply to Each for each case.

     

    This requires that the document folders are already made and the form choice response matches each case. This also doesn't allow for a single form response to send photos to different folders; that would get more complex.

     

    Do you think you can make it work like this?

    (If you get stuck, let me know, but also add a screenshot of your steps opened up fully so I can copy what you have. Then I'll make a complete example.)

  • elizabethharms Profile Picture
    22 on at

    It works! 

     

    Thank you so much for your help. I've been struggling with this all day. 

  • elizabethharms Profile Picture
    22 on at

    Well, I've found a new problem. The flow works and everything goes to the right document libraries. However, the files appear to be corrupted and won't open. It appears to be a problem with it going from OneDrive to the SharePoint List. Any ideas how to fix that? I can only find information about emails with corrupt attachments.

  • wskinnermctc Profile Picture
    6,519 Moderator on at

    Are the file names correct? More specifically, using the correct name with extension such as .docx or .pdf or .xlsx

     

    I have made the mistake of just using the file names and it doesn't work without the correct extension.

  • elizabethharms Profile Picture
    22 on at

    Yes, they are. It's putting my name at the end, but the extension is correct.

    elizabethharms_0-1687981577095.png

     

  • wskinnermctc Profile Picture
    6,519 Moderator on at

    So the files that are put into the list item as an attachment work correctly? You can open them up and they are not corrupted? 

     

    It is only the files that are being put into the SharePoint document library that are corrupted?

  • elizabethharms Profile Picture
    22 on at

    No. I thought they were fine because I could see the file name, but I don't think I had tried to open one previously. Now, when I try to open it from the SharePoint list, it doesn't open.

  • wskinnermctc Profile Picture
    6,519 Moderator on at

    Can you show a screenshot of your steps? Not just the steps and names (like in a previous photo of yours), but the steps expanded so I can see the values that are being used.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard