I have found this code to perform batch update
function updateListItems() {
var itemArray = [];
var clientContext = SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('TestList');
for(var i = 1; i<= 5; i++){
var oListItem = oList.getItemById(i);
oListItem.set_item('Title', 'My Updated Item!' + i);
oListItem.update();
itemArray[i] = oListItem;
clientContext.load(itemArray[i]);
}
clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);
}
function onQuerySucceeded() {
alert('Items Updated');
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
updateListItems();
But I am getting the following error :
The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
I need to update a various item in the list without iterating it.
Please Help!!