Deleting documents

Jun 20, 2014 at 3:00 PM
Edited Jun 20, 2014 at 3:02 PM
Hi,

Found a frustrating issue when deleting documents today - it seems that the BatchCMD xml really doesnt like the escaped '%20' space. Also found the solution - sharing so that this might help others.

Tried to follow the steps in this link - which correctly say that you need to pass the ID and the fileRef to the Batch cmd:

http://joshmccarty.com/2012/02/deleting-documents-with-spservices/

However, we hit a problem when the fileRef contains '%20' - since the library and filename contained a space.

If the ID and fileRef are themselves read from a 'getListItems' and the document library or fileRef contains a space '%20' - then the delete throws a 'do not have permissions' error.

A simple function is needed to parse the fileRef and replace '%20' with a space before passing the batchCMD xml.

Mike
Jun 21, 2014 at 3:59 AM
If you decode the URL prior to passing it in, it should work:
var url = "http://server/site/Lists/Working%20Docs";

console.log(url);

console.log(decodeURI(url));
I don't think I've ever ran into this problem, so the actual answer may be something else altogether. Whatever you find out, post back.

Cheers,
Matthew