I am having trouble deleting files from SharePoint. I get a 404 error but I am certain it is pointing to the right file.
I first thought it must have been a typo but after running Update file, which executes just fine this seems to be a bug with Delete File.
The process is as follows:
- Task with TaskID is completed
- Get row gets the row with TaskId, this row has a field called Subject
- Subject is the filename of the file to be deleted
- Delete file deletes the file - this is where it errors out
See screenshots for flow configuration and error message:
Thanks a lot.
Lukas
Solved! Go to Solution.
Hi again
The file you update is the same you want to delete, right?
If so, I have just tested it successfully by using an output from "Update file", see the following screenshot
Hope this helps
Proud to be a Flownaut!
Sorry for double post - I can't seem to figure out how to edit a post.
Here is the image of the error message:
Error Message
I guess the problem is with the File identifier you are using as input for SP DElete file action block.
I would suggest to add a "Compose" action block between "Update file" and "Delete file" and add "Path" (the one you are using for "Delete File") as input of the Compose action block, so you can inspect the content of its value
Hope this helps
Proud to be a Flownaut!
Hi again
The file you update is the same you want to delete, right?
If so, I have just tested it successfully by using an output from "Update file", see the following screenshot
Hope this helps
Proud to be a Flownaut!
Thanks for the swift response!
The only reason I had the update file action in there was to test the file identifier.
I tested your solution of using the Id of the Update file action and it worked. I don't know how because when I used the compose function after the update file, the file path was correct but Delete File failed. When I copied the output of compose and manually entered it in the File Identifier field, it worked. I think the problem is with the Subject variable coming directly from Get a row.
I will mark your solution as accepted but I think there is a bug in Delete file.
Thank you for your help
I agree, for some strange reason, values accepted as input for File Identifier in some action blocks are not valid in other related action blocks.
In the meantime, happy to see we found a reasonable workaround!
Proud to be a Flownaut!
Hi @lkaspar
The File Identifier field in the Delete file Action uses URI so if you have to change the '/' after the libaray name to
%252f
So in your case i would use the Identifier field from your Update File action or if you know the filename in your case you do if should be:
Shared Documents/General/Emails/[Subject].msg
Shared%20Documents%252fGeneral%252fEmails%252f[Subject].msg
[LibarayName]%252f[Filename].[extension]
You can also use the uriComponent() expression to turn you value into a URI value
Hope this helped.
Thanks a lot. This helped me resolve my current issue
@Anonymous
I cannot over state how much this has helped me. Thank you so much for your reply, hopefully others will find this thread. I have spent entirely waaaaayyyyyy to much time try to figure this out. Again THANK YOU!
I really appreciate the variety of approaches offered to this problem. In my case, I was triggering the flow from a link inside the doc library and I wanted to delete the file if it was already present before creating the file of that same name and causing an error. I decided to loop through all the files in the library with an Apply to Each loop and compare the file name with the file name I was intending to delete. If found, I deleted the file using its Identifier.
However.... After I did a Compose on the Identifier and learned that the Identifier was the same as the file name except that any spaces were replaced with _x0020_, I realized that it would have been easier to just create the Identifier in a function based on the file name and be done with it. I'll do that next time.
The accepted solution post isn't actually the solution.
What you need to do is take the site url and list name out into variables, then use delete item, and pass in the ID.
Delete file doesn't work properly when you pass the full file path in (for some illogical reason), and delete list item doesn't let you select document libraries (for some illogical reason).
Flows needs to be done better this is painful. One of countless grievances I have with this half baked product to replace workflows.
User | Count |
---|---|
98 | |
39 | |
27 | |
23 | |
16 |
User | Count |
---|---|
130 | |
52 | |
48 | |
36 | |
24 |