SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've searched the jQuery SPServices code examples and MSDN references for an simple example how to update several ListItems using a Where-Clause.

Code for updating a single ListItem with ID = 500, looks like this:

    operation: "UpdateListItems",
    listName: "MyList",
    ID: 500,
    valuepairs: [["MyField", 1]],
    completefunc: function (xData, Status) {

But is it also possible to add a Where like :

<Where><Eq><FieldRef Name="Status"/><Value Type="Text">Ready</Value></Eq></Where>

Or should I do it like this post ? (First retrieve the list and then do a loop for each item ?)

share|improve this question
up vote 2 down vote accepted

there. If you are using jQuery and the Web Services (hopefully with my SPServices library!), you have to do the two step process. Call GetListItems with your CAMLQuery first to get the items you need to work with and then call UpdateListItems to make the changes.

This isn't my design, by the way, it's just the way the SharePoint Lists Web Service works. When in doubt, always go to the source documentation on MSDN to see what each operation requires for parameters. I have links on all of the operations in SPServices which take you directly to the appropriate page on MSDN.

Finally, the Batch idea in UpdateListItems is a little bit misleading in its terminology. You can, in fact, "batch" requests into one UpdateListItems call, but you may or may not want to do that based on what your error handling requirements are. Again, best to check the SDK on MSDN.

EDIT: I added a new function to SPServices in v0.5.8 called SPUpdateMultipleListItems to do this:

share|improve this answer

I havent tried doing this specifically on jQuery, but you can for updating multiple list items using a batch update.

You use CAML to create batch commands and execute the command using ProcessBatchData method on SPWeb object.

Theres a good code sample on doing this on MSDN

share|improve this answer
I only want to use clientside jQuery and SPServices, so your solution is good, but not feasible for me. – Stef Feb 22 '10 at 14:11
fair enough, you will have to wait until Marc is back from vacation :-) – Anders Rask Feb 22 '10 at 21:52

His library does support a batch update, but I am not yet sure if the batch update supports a CAML query. If you are going to update multiple items, you could use the GetItems service with a CAML query to retrieve the items you want to update. You could then use the jQuery each on the return to then create an updateitems function for each item you want to update. Again, this is only feasible if you can't use a CAML query on a batch update.

share|improve this answer

I don't think it is available wihtout a Batch update.

share|improve this answer

I believe you'd have to query the list with your CAML query, then iterate through the results with your updates. That said, I did engage Marc to see if he can get you a formal answer on this.

share|improve this answer

SharePoint doesn't appear to natively support updating items based on a query at all, even using SPWeb.ProcessBatchData(). Quite a limitation, given the performance of trying to update each item by ID (even if it's with one big batch statement).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.