I'm trying to update some elements in a list with client object and caml query. It's working, my values are updated, but for all the items (around 15) even I have a rowlimit of 5 :
var collListItemToBeUpdated = "";
var listItemToBeUpdated = "";
function getItemsToBeUpdated() //this function called on button click to get ID's
{
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('Matériel Recyclage');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("<Query> <OrderBy> <FieldRef Name='ID' Ascending='False' /> </OrderBy> </Query> ");
camlQuery.RowLimit = 5;
collListItemToBeUpdated = oList.getItems(camlQuery);
clientContext.load(collListItemToBeUpdated);
clientContext.executeQueryAsync(getItemsToBeUpdatedSuccess, getItemsToBeUpdatedFailed);
}
function getItemsToBeUpdatedSuccess()
{
ListItemToBeUpdated= collListItemToBeUpdated.getEnumerator();
updateMultipleListItems();
}
function getItemsToBeUpdatedFailed(sender, args)
{
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
function updateMultipleListItems() //this function called on successfully getting ID's
{
var itemArray = [];
var clientContext = SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('Matériel Recyclage');
while(ListItemToBeUpdated.moveNext())
{
var oItem = ListItemToBeUpdated.get_current();
var oListItem = oList.getItemById(oItem.get_id());
oListItem.set_item('Palette', '1');
oListItem.update();
itemArray.push(oListItem);
clientContext.load(itemArray[itemArray.length-1]);
}
clientContext.executeQueryAsync(updateMultipleListItemsSuccess, updateMultipleListItemsFailed);
}
function updateMultipleListItemsSuccess()
{
alert('Items Updated');
}
function updateMultipleListItemsFailed(sender, args)
{
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
Can you tell me why the RowLimit attribute isn't working?