I am making windows tool using sharepoint client object model. I have two custom lists one as source list and another as destination list hosted in sharepoint. In both the lists there is column Application ID which will act like unique key.

I have a button update list which will update the destination list item in batch if Application ID of source list is equal to Application ID of destination List.

Please guide me how to prcodeed .

Thanks Rakesh


Following is an example of batch updating list items:

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);  
        itemArray[i] = oListItem;

    clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);

function onQuerySucceeded() {

    alert('Items Updated');

function onQueryFailed(sender, args) {

    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

Notice that query is executed at the end after loading all items in the for loop.

Source: http://www.vrdmn.com/2013/07/batch-operations-using-javascript.html

  • If he is making a windows application, perhaps using C# and Microsoft.SharePoint.Client is more appropriate? Although the code would be very similar. And do you really need the .load?
    – eirikb
    Mar 18 '14 at 6:29
  • You are right Managed client object model will make more sense than Javascript client object model. However, .Load will still be needed and executeQueryAsync will change to ExecuteQuery() Mar 18 '14 at 6:40
  • .load is for loading data, not updating, I would just call update. This code should work perfectly: c=SP.ClientContext.get_current(),i=c.get_web().get_lists().getByTitle('Test').addItem();i.set_item('Title','test');i.update();c.executeQueryAsync(), and it can be looped (batched) just as well as far as I know
    – eirikb
    Mar 18 '14 at 6:46
  • Hi eirikb, You are correct I am using C#. But I need to compare two columns i.e. application IDs from both the lists and than update item if both items have same value of application. For that I used CAML query but no success. Please help.. Mar 18 '14 at 6:59
  • @rakeshpandey You should share the CAML query and the code you have written so far. Mar 18 '14 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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