this.DraftBatchDelete = function (ID, primaryCtrl) {
debugger;
var confirmStrings = { text: "Are you sure you want to remove?", title: "Confirm" };
var confirmOptions = { height: 200, width: 450 };
var msg = "";
var selectedIds = ID;
var blCanSubmit = true;
var selectedRows = primaryCtrl.getGrid().getSelectedRows();
console.log("choose" + selectedRows.getLength() + " records.");
if (selectedRows.getLength() === 0) {
msg = "Please select at least one item!";
blCanSubmit = false;
}
if (blCanSubmit) {
Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
function (success) {
if (success.confirmed) {
Xrm.Utility.alertDialog("Removing data, please wait..."); // useful
Xrm.Utility.showProgressIndicator("Removing data, please wait...");//not work
selectedRows.forEach(function (row, i) {
var entityId = row.getData().entity.getId().replace('{', '').replace('}', '');
var entity = {};
entity.statecode = 1;
Xrm.WebApi.online.updateRecord("crb94_xxxxxx", entityId, entity).then(
function success(result) {
var updatedId = result.id;
console.log(updatedId);
parent.window.location.reload();
},
function (error) {
Xrm.Utility.alertDialog(error.message);
}
);
});
Xrm.Utility.closeProgressIndicator();
}
}
);
}
else {
Xrm.Utility.alertDialog(msg);
}
}