Posts

Showing posts from August, 2014

Bulk update and delete using SPservice in SharePoint

$().SPServices.SPUpdateMultipleListItems({ listName: "States" , CAMLQuery: "<Query><Where><Eq><FieldRef Name='Status'/><Value Type='Text'>Active</Value></Eq></Where></Query>" , valuepairs: [["Status", "Inactive"]] }); This call to SPUpdateMultipleListItems will update all of the items in the States list which have their Status = "Active", setting their Status = "Inactive". $().SPServices.SPUpdateMultipleListItems({ listName: "States" , CAMLQuery: "<Query><Where><Eq><FieldRef Name='Status'/><Value Type='Text'>Inactive</Value></Eq></Where></Query>" , batchCmd: "Delete" }); This call to SPUpdateMultipleListItems will delete all of the items in the States list which have their Status = "Inactive".

Delete the document using SPServices

function deleteFile ( itemID , fileRef , listName ) { // This is the command needed to delete the specified file. It uses the ID and the URL of the file name. These values must be passed into this function when calling it. var batchCmd = "<Batch OnError='Continue'><Method ID='1' Cmd='Delete'><Field Name='ID'>" + itemID + "</Field><Field Name='FileRef'>" + fileRef + "</Field></Method></Batch>" ; // Use SPServices to delete the file. $ (). SPServices ({ operation : "UpdateListItems" , async : false , listName : listName , updates : batchCmd , completefunc : function ( xData , Status ) { // Check the error codes for the web service call. $ ( xData . responseXML ). SPFilterNode ( 'ErrorCode' ). each ( function (){ responseError = $ ( this ). text (); // If the error codes indicate...