function DeleteCrossChargeTransactions(vReferenceId)
{
try
{
var contextDelete = new SP.ClientContext.get_current();
var webDelete = contextDelete.get_web();
var listDelete = webDelete.get_lists().getByTitle('Cross Charge Details NA');
var queryDelete = new SP.CamlQuery();
queryDelete.rowLimit=100;
queryDelete.set_viewXml('<View Scope=\'RecursiveAll\'><Query><Where><Eq><FieldRef Name="Reference_x0020_Id" /><Value Type="Text">'+vReferenceId+'</Value></Eq></Where></Query></View>');
// add your query to the getItems command for your list
this.collListItemsDelete = listDelete.getItems(queryDelete);
// issue the load command, these can be batched for multiple operations
contextDelete.load(collListItemsDelete);
// execute the actual query against the server, and pass the objects we have created to either a success or failure function
contextDelete.executeQueryAsync(Function.createDelegate(this, this.SuccessFunction), Function.createDelegate(this, this.failed));
}
catch(e)
{
}
}
function SuccessFunction()
{
var itemsToDelete = new Array();
var count = this.collListItemsDelete.get_count();
//alert("Rc count:"+ count);
var listEnumerator = this.collListItemsDelete.getEnumerator();
var contextDelete= new SP.ClientContext.get_current();
while (listEnumerator.moveNext()) {
var item = listEnumerator.get_current();
// var s=item.get_item("Reference_x0020_Id");
itemsToDelete.push(item);
}
for (var i = itemsToDelete.length-1; i >= 0 ; i--) {
itemsToDelete[i].deleteObject();
//alert('Deleted:'+ i);
}
contextDelete.executeQueryAsync(Function.createDelegate(this, this.allItemsDeleted), Function.createDelegate(this, this.failed));
}
No comments:
Post a Comment