Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

I am unable to delete a document library file by JavaScript code.

$
0
0

Below is the error code as well as my code. How can I fix this error please?

Request failed: ServerRelativeUrl Parameter name: Specified value is not supported for the serverRelativeUrl

function deleteFile(fileName)  

  alert('delete file is reached.');

  alert(fileName);

   var clientContext; 

  var oWebsite; 

  var fileUrl2 =  "mySharePointsiteurl/Shared Documents/";

  fileUrl2 +=  fileName;

  alert(fileUrl2);

   clientContext = new SP.ClientContext.get_current(); 

  oWebsite = clientContext.get_web();

  clientContext.load(oWebsite);

  this.fileToDelete = oWebsite.getFileByServerRelativeUrl(fileUrl2);

this.fileToDelete.deleteObject();

clientContext.executeQueryAsync(

Function.createDelegate(this, this.successfileDeletionHandler),Function.createDelegate(this, this.errorfileDeletionHandler)

);

}

function successfileDeletionHandler()  

  alert('the file has been deleted. You can verify the deletion by checking the document library.');

}

function errorfileDeletionHandler() { 

  alert('Request failed: ' + arguments[1].get_message()); 


faye fouladi


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>