Skip to content

Instantly share code, notes, and snippets.

@vman
Created July 15, 2013 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vman/6002265 to your computer and use it in GitHub Desktop.
Save vman/6002265 to your computer and use it in GitHub Desktop.
function deleteListItems() {
var clientContext = SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('TestList');
for(var i = 0; i<= 5; i++){
var oListItem = oList.getItemById(i);
oListItem.deleteObject();
}
clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);
}
function onQuerySucceeded() {
alert('Items Deleted');
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
deleteListItems();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment