0

I'm getting the following error when updating a listitem

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. Microsoft.SharePoint.Client.ServerException

I'm doing a number of updates on a listitem and need to call update for the changes to take affect to then perform the next operation. Is it possible to detect when the first update has completed successfully and then do the next update.

Or is there another way, I'm doing two updates on this listitem. I'm also checking out the item before and after.

Microsoft.SharePoint.Client.File file = clientContext.Web.GetFileByServerRelativeUrl(u.LocalPath);
                ListItem listItem = file.ListItemAllFields;
                clientContext.Load(listItem);
                clientContext.ExecuteQuery();
                file.CheckOut();
                listItem["Title"] = "Title Updated";
                listItem.Update();
                clientContext.ExecuteQuery();
                listItem.RefreshLoad();
                clientContext.ExecuteQuery();
                object title = listItem["Title"];
                listItem["Title"] = "Title Updated After refresh";
                listItem.Update();
                file.CheckIn("Test", CheckinType.OverwriteCheckIn);
                clientContext.ExecuteQuery();

The above code looks to work. If I make a change in the WEB UI and put a breakpoint on listItem.RefreshLoad(); I get the value entered in the UI.

Is there a way to determine if a update or executequery has completed on the server side?

3
  • 1
    can you put some part of your code
    – Gaurravs
    Jun 17 '16 at 7:25
  • Please provide your code efforts so someone can understand your problem properly. Jun 17 '16 at 7:59
  • @Gaurravs sample added
    – Webfort
    Jun 17 '16 at 8:21
1

if this was on-premises I would suggest using SystemUpdate instead of Update, but as this is SP Online, what might work for you is to re-get the item between updates. So do your first update and ExecuteQuery, then get the ListItem again and ExecuteQuery before performing the second update.

Hope this helps.

1
  • I've updated my post with some sample code.
    – Webfort
    Jun 17 '16 at 8:22
0

Use different listitem object for different update operations. Create new object for another update operation. Using the same object will throw this type of exception.

And another important thing, if you are using event receivers on item adding or updating then use this.eventenabled = false; Refer this link

For example:

Microsoft.SharePoint.Client.File file = clientContext.Web.GetFileByServerRelativeUrl(u.LocalPath);
            ListItem listItem = file.ListItemAllFields;
            clientContext.Load(listItem);
            clientContext.ExecuteQuery();
            file.CheckOut();
            listItem["Title"] = "Title Updated";
            listItem.Update();
            clientContext.ExecuteQuery();
            listItem.RefreshLoad();
            clientContext.ExecuteQuery();
            object title = listItem["Title"];

//Create new object for another update operation
            ListItem newListItem = file.ListItemAllFields;
            newListItem["Title"] = "Title Updated After refresh";
            newListItem.Update();
            file.CheckIn("Test", CheckinType.OverwriteCheckIn);
            clientContext.ExecuteQuery();

Hope this will help you.

1
  • thanks for your answer, another thing I forgot to mention is this error does not occur for every item I am updating. out of the 3000 files being updated only 12 of them failed with this error.
    – Webfort
    Jun 17 '16 at 8:50

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.