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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to save most recen...
Power Automate
Unanswered

How to save most recent attachments to a folder?

(0) ShareShare
ReportReport
Posted on by 387

Hi fellow PA veterans,

 

May I know How I could create a flow to get the most recent SharePoint attachments and save them in a folder?

 

Kindly see attached image for your reference.

>My 'Get Attachments' action always just pick up the attachments from the first row of my list. 

>My 'Create file' action for the folder creation would return an error when I re-submits new attachments. 'Folder with the same name already exists."

 

flow.jpg

 

Hope someone could point me out where I've got it wrong. Thanks in advance.

Categories:
I have the same question (0)
  • Mira Ghaly Profile Picture
    11,413 Moderator on at

    @Australia

    Can you try the solution suggested in the below post:

    https://powerusers.microsoft.com/t5/Building-Flows/Create-File-with-SharePoint-Connector-with-same-names/m-p/660880#M88821

     

  • Australia Profile Picture
    387 on at

    @Mira_Ghaly , thanks again for your reply.

    I am afraid the recommended solution for me. I actually have the trigger of my flow coming from Power Apps. Could it be the problem?

    Error: "You may break your PowerApps triggered flow with the changes on the triggers"

     

    I've also been trying another similar solution I found but received the same error:

    https://docs.microsoft.com/en-us/answers/questions/82189/copy-attachments-from-existing-sharepoint-list-to.html

     

  • v-litu-msft Profile Picture
    on at

    Hi @Australia,

     

    You could create a Get file metadata action to run if the Create file action failed. How to set the Configure run after you could refer to screenshots as below:Screenshot 2020-10-20 153356.jpg

     

    Screenshot 2020-10-20 153410.jpg

     

    If the file hasn't existed in the folder, the create file action could run successful, and Get file metadata and Update file action won't run;

    If the file already exists in the folder, the create file action will failed cause already has same name file, but the Get file metadata action could run to return File Identifier, then you could use file identifier and Attachment content to update the file.

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • Australia Profile Picture
    387 on at

    @v-litu-msft Thanks for coming back to visit and answer my thread. Much appreciated.

    I understand that the 'Get file metadata using path' is used to check if a file(s) already exists in a folder.

    But what if I also want to check if a folder already exists in a document library?

    i.e. Check if a folder already exists then check if a file(s) already exists in the folder

     

    Thank you.

  • v-litu-msft Profile Picture
    on at

    Hi @Australia,

     

    Yes, you could use Get folder metadata to check the folder if exist.

    If it exists, the action could work successful, or it will fail:

    Screenshot 2020-10-21 112632.jpg

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Australia Profile Picture
    387 on at

    @v-litu-msft Thanks Lin Tu.

    Am I correct to say that for the full working Flow to work I should do the following:

     

    Triggered by a Power App Save button >  Get Attachments > Apply to each (Get Content > Compose (folder) >Get folder meta data > Create File?

     

    The desired output is:

    Document Library/John Smith - 20.10.2020 (this folder naming convention is defined in PowerApps) /attachments x.pdfy.pdfz.pdf
    (where z.pdf is the only new attachment, the other two are existing attachments)

    The Flow checks if there's a folder already exists. If yes, save z.pdf in that folder otherwise create a new folder and save z.pdf there.

     

    Thank you again.

  • v-litu-msft Profile Picture
    on at

    Hi @Australia,

     

    "The Flow checks if there's a folder already exists. If yes, save z.pdf in that folder otherwise create a new folder and save z.pdf there."

     

    If so, there is no need to check the folder if already exists. The path should:

    1. Triggered by a Power App Save button

    2. Get Attachments

    3. Apply to each (Get Content > Compose (folder))

    4.1 Create File (If there is no corresponding folder exists, create file action will create a folder automatically)

    4.2 if create file failed means there is the same name file exists. Then go to update file.

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • persona Profile Picture
    13 on at

    Sorry, replied on wrong thread

  • Australia Profile Picture
    387 on at

     

    @v-litu-msft thank you for the reply.

    I just tried to create the flow based on the instruction, but it seems I am missing file content?

    I would be very grateful if you could shed some light on this. Kindly see below a screenshot of my flow.

    Many thanks.

     

     

     

     

     

     

  • Verified answer
    v-litu-msft Profile Picture
    on at

    Hi @Australia,

     

    Steps as below, hope it could help you:

    Screenshot 2020-10-23 170405.jpg

     

    Screenshot 2020-10-23 170519.jpg

     

    Run status 1, there is no same name file exists:

    Screenshot 2020-10-23 170244.jpg

    Run status 2, there is already same name file exists:

    Screenshot 2020-10-23 170338.jpg

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard