cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
koneill
Regular Visitor

Power Automate Flow Creating/Updating File in Proper Folder Path

All,

In the following Power Automate I currently have this working so that when a file is uploaded to a
working document library and is then approved it gets converted to a .pdf (using OneDrive since I don't have a premium connector) - then gets created in the main document library.

However what do I need to do so that the file is created/updated in the folder structure it was uploaded to.
so that it's all kept in place.

Example - the working document library has a Process folder so when a user uploads to that Process folder
I want the approved .pdf file that gets created/updated to be created/updated in the main document libraries Process folder.

power_automate_approval_create_in_spo.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Super User
Super User

Hi @koneill 

 

What trigger are you using?  If it is When a file is created in a folder, you could use the following expression in your final create file action:

replace(base64ToString(triggerOutputs()?['headers/x-ms-file-path-encoded']),base64ToString(triggerOutputs()?['headers/x-ms-file-name-encoded']),'')
Which takes the file path including filename, (converts base64tostring) and replaces the filename with ''.
 
Something to bear in mind, if you are creating a file in the same folder as the original trigger, your flow will trigger again.  You will need to implement a trigger condition where the flow won't run.  Maybe on the filename ending with .pdf?  I've a video on trigger conditions here https://youtu.be/tlS6pSAx-GY.
 
A sample trigger condition expression might be:
@not(endswith(base64ToString(triggerOutputs()?['headers/x-ms-file-name-encoded']), '.pdf'))
 

Please consider accepting my answer as a solution if it helps to solve your problem.

Cheers
Damien

Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts, or take a look at my website. Thanks

View solution in original post

2 REPLIES 2
DamoBird365
Super User
Super User

Hi @koneill 

 

What trigger are you using?  If it is When a file is created in a folder, you could use the following expression in your final create file action:

replace(base64ToString(triggerOutputs()?['headers/x-ms-file-path-encoded']),base64ToString(triggerOutputs()?['headers/x-ms-file-name-encoded']),'')
Which takes the file path including filename, (converts base64tostring) and replaces the filename with ''.
 
Something to bear in mind, if you are creating a file in the same folder as the original trigger, your flow will trigger again.  You will need to implement a trigger condition where the flow won't run.  Maybe on the filename ending with .pdf?  I've a video on trigger conditions here https://youtu.be/tlS6pSAx-GY.
 
A sample trigger condition expression might be:
@not(endswith(base64ToString(triggerOutputs()?['headers/x-ms-file-name-encoded']), '.pdf'))
 

Please consider accepting my answer as a solution if it helps to solve your problem.

Cheers
Damien

Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts, or take a look at my website. Thanks

View solution in original post

koneill
Regular Visitor

@DamoBird365 Many thanks for the information I started to set this up. I was thinking about using the When a folder is created but then I wasn't sure if I needed similar steps for getting the files metadata - if I also need to do that for the folder as well so it carries over into the final document library where approved items will be output.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,326)