cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ITGuyinMD
Frequent Visitor

Trouble with deleting docx files from library

Hello. I'm new to PA. I have created a Word template where after I fill in fields in a sharepoint form it uses Power Automate to generate a .docx and then convert to the pdf and those are created in a sharepoint library.  My flow works until that point. I now need to add a delete action to delete all of the word docs and allow the pdf docs to stay in the library by themselves. The name of the file is dynamic, so the first part is always the name of the user taken from the "full name" field of the form and then "Driving record authorization.pdf comes after that (below). Both create file fields are the same (one for the doc x and one for the pdf)

flow 3.PNG

The delete action doesn't work with that syntax and throws an error that it is not in a json format (below is the setup).

 

flow 2.PNG

I then went back to the drawing board again with new info and pasted the info into a encodeuricomponent field, but it throws the error "the expression is invalid".  The code is encodeUriComponent(/Driving Record Forms/outputs('Get_response_details')?['body/r52e0be9f78e541bcb6b0ec6a785ad325']/Driving Record Authorization.docx). I'm not sure the syntax is correct with the above code.

 

To sum it up, I have a library that has 2 documents created with the same name from a form, but I need to delete the dynamically named word docs after they are used to convert to the pdf. I thought this would be easy, but it has turned out to be the hardest part. Any pointers in the right direction would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
v-LilyW-msft
Community Support
Community Support

Thank you for posting.

According to your description, You want to delete the docx file in one folder and only save PDF file with the same name. If any misunderstanding, please kindly let me know.

Please select the 'Id' from 'Create file' in File identfier and try again

vLilyWmsft_0-1623840732070.png

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.

View solution in original post

2 REPLIES 2
v-LilyW-msft
Community Support
Community Support

Thank you for posting.

According to your description, You want to delete the docx file in one folder and only save PDF file with the same name. If any misunderstanding, please kindly let me know.

Please select the 'Id' from 'Create file' in File identfier and try again

vLilyWmsft_0-1623840732070.png

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.

View solution in original post

Hello. That got me close. It deleted the PDF and kept the word doc. So I switched the delete file action to be in between the "convert word document to pdf" and the "create file 2" action and it deleted the previous word document created with the "create file" action. Thanks for your help on this issue. Just so it can help someone else, I put the flow below.

 

ITGuyinMD_0-1623849378375.png

 

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.

Top Solution Authors
Users online (2,859)