EnjoySharePoint YouTube Channel

Delete multiple items in batch using SharePoint 2013 default services

This SharePoint tutorial, we will discuss how to delete multiple items in batch using SharePoint 2013 default services. have to delete multiple documents/items we can use REST api but we have to make ‘n’ number of calls to delete ‘n’ number of Rows. Major performance hit I believe. Here we can easily use SharePoint default Lists.asmx Service to delete multiple rows.

Get Office 365 Enterprise E3 Or Business Premium Subscription & Try out all the features

We all have been using REST api to do different types of CRUD operations but there is also another way to do the CRUD operations. All we need is to use SharePoint default Services like:
1. Copy.asmx
2. Lists.asmx
3. Versions.asmx
4. UserGroup.asmx
5. Permissions.asmx
6. Views.asmx and many more.

Why to use ?
1. It is already prewritten and all we have to do is just consume it .
2. No overhead of service deployment .
3. Easily you can perform BATCH operations .

if(location.href.indexOf(“TestPage-for-Batch-Operations.aspx”)>-1) {
$(document).ready(function () {

function delete(siteurl) {
//let say I want to delete item Ids 465 , 466 and 486
var obj=[];
var fields = “”;

//framing the Rows to be deleted .Here I have deleted w.r.t ID but it can be any column name
for(var i=0;i<obj.length;i++){
fields += “<Method ID=\””+obj[i]+”\” Cmd=\”Delete\”><Field Name=\”ID\”>” + obj[i]+ “</Field></Method>”;

var batch = “<Batch OnError=\”Continue\”>” + fields + “</Batch>”;
var soapEnv = BuildSoapEnv(batch, ‘Master Document Transmittals’);
DeleteBatchItems(soapEnv, onSuccessDelete,siteurl);

//Bulid SOAP Envelope having the full request
function BuildSoapEnv(batch, listname)
var soapEnv =
“<?xml version=\”1.0\” encoding=\”utf-8\”?> \
<soap:Envelope xmlns:xsi=\”http://www.w3.org/2001/XMLSchema-instance\” \
xmlns:xsd=\”http://www.w3.org/2001/XMLSchema\” \
xmlns:soap=\”http://schemas.xmlsoap.org/soap/envelope/\”> \
<soap:Body> \
<UpdateListItems xmlns=\”http://schemas.microsoft.com/sharepoint/soap/\”> \
<listName>” + listname + “</listName> \
<updates> \
” + batch + “</updates> \
</UpdateListItems> \
</soap:Body> \
return soapEnv;
//Perform Delete operation in a Batch
function DeleteBatchItems(soapEnv, functionToCall,siteurl)
url: siteurl+ “/_vti_bin/Lists.asmx”,
beforeSend: function(xhr) {
//to avoid security validation error SOAPAction header must be provided
type: “POST”,
dataType: “xml”,
data: soapEnv,
complete: functionToCall,
contentType: “text/xml; charset=\”utf-8\””
function onSuccessDelete()
// do something

Read SharePoint branding tutorials

Hope this will be helpful.

Check out Best Alternative to InfoPath -> Try Now
You May Also like the Following SharePoint Tutorials: