1

I have an Announcements list, that has date/time column called 'Expires', where we specify what date that item is going to expire. I also have a yes/no column called 'Expired'.

I have a JavaScript code that displays the items in this Announcements list in a content editor web part. This JavaScript displays only items that are NOT expired.

Now I want to also update this 'Expired' column, if the item's 'Expires' date is less than today's date.

In my JavaScript I have a function that updates this 'Expired' column. The function that does that is the following:

 function updateListItem() {

SP.SOD.executeFunc('sp.js','SP.ClientContext', function () {    
    clientContext = new SP.ClientContext();

var  Noweb = clientContext.get_web();
var  Nolists = Noweb.get_lists();
var  Nolist = Nolists.getByTitle('Announcements');

var  NoListItem = Nolist.getItemById(14);

NoListItem.set_item('Expired', '1');

NoListItem.update(); 

clientContext.executeQueryAsync(Function.createDelegate(this, qs_announcementlistitem),Function.createDelegate(this, qf_announcemenlistitem)); 
});

}

It does update the 'Expired' column but I get 'Save Conflict. Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes.' if I try to manually edit THAT item.

I have two clientContext.executeQueryAsync functions in my javascript code. One in the main function to retrieve the items in the list and one in the function above.

How do I resolve this conflict in javascript.

Much Obliged for the answers.

0

My first guess here is that your sending the request more than once. The first request is executing the update, and immediately there is a second request trying to do the same thing - thus you get the error, but the update works.

you can use the Dev tools in your browser to see if you are making multiple calls to update that list and where that is happening. You can either look at the Network request - or set a break point on your function and see how many times it's called.

Edit

Also - enable version history on your list so you can see what updates are being made, and in what order.

  • @ Jesus Shelby. The first request is just getting the items from the list to display in the web part. That's all the first request does. There is no updating in that request. It is the second request that updates the item. – Aziz Qureshi Oct 10 '14 at 17:00
  • Check to see that your updatelistitem() is not executing more than once. Also I added an edit - that can help track interactions on the list side. – Jesus Shelby Oct 10 '14 at 17:05

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.