set_item() does and what
Below is some code to illustrate.
Boilerplate code to get the list items:
var ctx = SP.ClientContext.get_current(); var list = ctx.get_web().get_lists().getByTitle('Employees'); var listItems = list.getItems(""); ctx.load(listItems, "Include(Name, Role)"); ctx.executeQueryAsync(onSuccess, onFailure);
first set of commands
var first = listItems.getItemAtIndex(0); var second = listItems.getItemAtIndex(1); first.set_item("Role", "foo"); second.set_item("Role", "bar"); second.update(); // only call update on the second item ctx.executeQueryAsync(onSuccess, onFailure);
The actual network request to SharePoint contains two "SetFieldValue" methods with "foo" and "bar", and only one "Update" method for the second one. SharePoint only updated the second value with "bar".
second set of commands
first.update(); ctx.executeQueryAsync(onSuccess, onFailure);
The second request contains only a single Update method. SharePoint did not update the first value with "foo".
Why is the first item sent even though update was not called?
first.update() is called, the new value is not passed again - but I would at least assume that it would be staged in SharePoint, waiting for the
update() - but that doesn't happen.