We have a process that creates a subfolder within a designated OneDrive folder and one or more files inside that subfolder. I would like to create a flow that copies the newly-created subfolder and all of its contents to Sharepoint. As an example, our process creates /root/Submit/subfolder1/file1 and /root/Submit/subfolder1/file2. I want subfolder1, file1 and file2 copied to Sharepoint. Here's what I have so far. The "When a file is created" trigger is configured to include subfolders.
This works great for subfolder1, but when subfolder2 is created subfolder1 is copied to Sharepoint again, in addition to subfolder2. All I want is the most-recently created subfolder and its contents. Is there a way to capture the parent folder of a newly-created file and only operate on that folder instead of the grandparent (in my case, "Submit")?
Solved! Go to Solution.
No apologies necessary. I should have noticed that in your original reply.
After adding that piece, there was only one thing missing. The "Submit" folder was also replicated in SharePoint, whereas I only need to capture the parent folder of the new file. I made some adjustments and now have a flow that meets my needs. I'm including it below for posterity. If you see any glaring flaws please do let me know, but otherwise I consider this issue resolved. Thanks very much for your time.
Compose
split(last(split(outputs('Get_file_metadata')?['body/Path'],'root:')),'/')
Get New Subfolder
last(take(outputs('Compose'),sub(length(outputs('Compose')),1)))
Hi @esaunders
I set up a Flow and can achieve your needs.
Please take a try with the screenshots as below:
Expression:split(last(split(outputs('Get_file_metadata')?['body/Path'],'root:')),'/')
Expression:length(outputs('Compose'))
Expression:join(take(outputs('Compose'),add(outputs('Compose_2'),-1)),'/')
When the new file is created in subfolder2 of OneDrive.
It will be created in subfolder2 of Sharepoint.
Hope the content above may help you.
Best Regards
If my solution helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you, @v-LilyW-msft! Your proposed flow works great for copying newly created files, but I also need to copy over their newly created parent folder as well. So if our process creates subfolder1/file1 in the Submit folder the flow should also create subfolder1/file1 on SharePoint. Any suggestions appreciated.
Hi @esaunders
Have you tried to reproduce my Flow?
According to my solution, if you create a new folder and then create a file in the new folder, both the new file and the new folder will be created in sharepoint. No need to add additional step to create a new folder.
E.g: new folder and new file are created in OneDrive
The new folder and new file in sharepoint are automatically created after Flow runs.
Hope the content above may help you.
Best Regards
If my solution helps, then please consider Accept it as the solution to help the other members find it more quickly.
I did try to reproduce your flow, but I'm not seeing the behavior you describe.
I create a new folder and file in OneDrive.
But after running the flow, "newfolder" is not included in SharePoint.
Hi @esaunders
Sorry, I didn't mark it clearly.
Please change 'esaunders-TEST' to the Outputs of Compose 3 after'/Shared Documents/' in Folder Path.
Like this:
Hope the content above may help you.
Best Regards
If my solution helps, then please consider Accept it as the solution to help the other members find it more quickly.
No apologies necessary. I should have noticed that in your original reply.
After adding that piece, there was only one thing missing. The "Submit" folder was also replicated in SharePoint, whereas I only need to capture the parent folder of the new file. I made some adjustments and now have a flow that meets my needs. I'm including it below for posterity. If you see any glaring flaws please do let me know, but otherwise I consider this issue resolved. Thanks very much for your time.
Compose
split(last(split(outputs('Get_file_metadata')?['body/Path'],'root:')),'/')
Get New Subfolder
last(take(outputs('Compose'),sub(length(outputs('Compose')),1)))
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
26 | |
24 | |
23 | |
14 | |
10 |
User | Count |
---|---|
57 | |
55 | |
29 | |
27 | |
24 |