Save conflict when checking in and updating column RRS feed

  • Question

  • I have written an event receiver which updates a column on check in, but it is giving me a Save conflict error

    What am I doing wrong?

    Code below:

     override void ItemCheckingIn(SPItemEventProperties properties)
    SPContentType cT = properties.ListItem.ContentType;
    String ctName= cT.Name;
    String rejectedcT = "Migrated";
    Object ManualDisposal = properties.ListItem["ManualDisposalSet"];
    Object DisposalDate = properties.ListItem["DisposalDate"];
    Object DocRetention = properties.ListItem["DocRetention"];
    SPListItem listItem = properties.ListItem;
    //if not migrated
    if(ctName != rejectedcT){
    //If Manual disposal flag isn't set
    if (ManualDisposal == null)
    //if disposal date manually entered validate if valid, set manudal disposal. Now can be saved
    if (DisposalDate != null)
    "ManualDisposalSet"] = "True";

    Thursday, December 22, 2016 3:59 PM

All replies

  • Hi,

    Add your code between the if loop block

    int beforeLevel = (int)properties.BeforeProperties["vti_level"];
        int afterLevel= (int)properties.AfterProperties ["vti_level"];
        if((beforeLevel==255) && (afterLevel==1))
    //Your code logic to update the Major version of the item

    Murugesa Pandian | MCPD | MCTS | SharePoint 2010 |

    Thursday, December 22, 2016 6:37 PM
  • the list item does not get updated then
    Friday, December 23, 2016 8:36 AM
  • The reason for the save conflict is:

    The item is being checked in and therefore the item updated event and item checked in event are going to be executed.

    and in your code you are running the following command:

     listItem["ManualDisposalSet"] = "True";

    To avoid conflict you always need to use AfterProperties instead of listitem["columnname"] in your synchronous event.

    You need to change this to either

     properties.AfterProperties["ManualDisposalSet"] = "True";


    properties.EventFiringEnabled = false;
    properties.AfterProperties["ManualDisposalSet"] = "True";
    properties.EventFiringEnables = true;

    I have not tested this code and the only concern I have is that it might lock the update since the file is checked out to a user.

    If it still does not work then you need to work on the ItemCheckedIn event and re-checkout the item to perform your update.

    Regards, Huzefa Mala, MCPD, MCT Please mark the post that answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    Friday, December 23, 2016 9:34 AM
  • Hi,

    Is any update for your issue?

    Best Regards,


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Tuesday, December 27, 2016 6:25 AM