1

here is My code :

console.log(query);
camlQuery.set_viewXml(query);
collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(function (sender, args)
                                    {
                                        var itemArray = [];
                                        var i=0;
                                        var listEnumerator = collListItem.getEnumerator();
                                        while (listEnumerator.moveNext()) 
                                        {

                                                var listItem = listEnumerator.get_current();
                                                var item=listItem.get_item('ID');

                                                listItem.set_item('Flex_status',hash [item][7]);
                                                listItem.set_item('Payroll_recieved_date',hash[item][8]);
                                                listItem.get_item('Flex_Paid_Date',hash[item][9]);
                                                listItem.get_item('Payroll_Comments',hash[item][10]);

                                                listItem.update();
                                                itemArray.push(listItem);
                                                clientContext.load(itemArray[itemArray.length-1]);
                                        }
                                        clientContext.executeQueryAsync(function (sender, args)
                                                                        {
                                                                            alert('done...');
                                                                            $('#hh').modal('toggle');
                                                                        }, function (sender, args)
                                                                        {

                                                                            alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
                                                                            $('#hh').modal('toggle');
                                                                        });

                                    },function (sender, args)
                                    {
                                        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

                                    //$('#hh').modal('toggle');
                                    });

The Problem is got the alert saying done but when i refreshed the list my items were not upgraded...i have cross checked every variable in debugger...Can any one help me please

3
  • 3
    You may want to check out Marc Anderson's SPServices library for jQuery. Write less, do more.
    – teylyn
    Commented Jul 19, 2016 at 11:10
  • 1
    Try removing second clientcontext.load function call Commented Jul 19, 2016 at 11:19
  • @ teylyn i can do that but i have requirements while updating list items therefore cant go for it....if you can help me in the above code that will be great....thanks for reply
    – Shomit
    Commented Jul 19, 2016 at 11:20

1 Answer 1

1

The itemArray is not needed (unless you are using it elsewhere) because this line: clientContext.load(itemArray[itemArray.length-1]); is also not needed and may in fact be causing you problems. To update a list item all you need is that update() call followed by the clientContext.executeQueryAsync call.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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