Example of Batch Updating List Items in SharePoint 2013 based on a query using Client Object Model and Jquery.
In this example we will look at a Script where we make an Ajax call to GetlistItems web service and pass a CAML query to retrieve all Items with "Project Cost" greater than $1000 (as seen in the Before Projects list screen below). Once the Items are Retrieved (based on a "Project Cost" CAML query), we Create a Update Batch of these Items and pass it to the UpdateItems method.The UpdateItems method finally updates the required Items in the Projects List with the appropriate Status (see the After Image below).
Final Result – After running the Batch update script, all the Items with "Project Cost" > $1000 will have an updated Status of "Transferred" in the Custom Project List that we have Created.
Before :
After :
To begin,
1. Download the Script and add it to Script Editor or Content Editor WebPart on your Lists Page. 2. Edit the listname, Column names and Value for the CAML query and update batch (in AddTobatch() method). 3. Once done Save and Click the link "Update Status for Items with Project Cost >$1000″ to update the Items that are retrieved from the CAML query. 4. Once updated a Confirmation message – "Update Complete" is displayed.