locked
Prevent Concurrence Item editing RRS feed

  • Question

  • Here is my issue if two people are editing a list time at the same time the first to click ok changes are saved.  I want to avoid this issue by putting an error message on the list item when someone enters if someone else is already editting the item. maybe this canbe done by java script or something. any help is greatly appreciated.

    sorry wanted to add I am not talking about documents or document libraries.  I am talking about custom lists
    • Edited by DavidLewis27 Wednesday, May 11, 2011 3:32 PM forgot a piece
    Wednesday, May 11, 2011 3:31 PM

Answers

  • Hey David,

    What happens if a user opens up a page to edit the list item and then decides to just close their browser? How will you know it's not being edited anymore since the user didn't save or cancel their action? I think that is going to be your biggest issue using any straight jQuery approach to check to see if "someone else is editing". 

    I'm sure there are other options, but a quick and dirty approach would be:

    1) When a user goes to edit an item save the modified date in a variable.

    2) When the user clicks to save the item, BEFORE THE SAVE do a jQuery call using SPServices (http://spservices.codeplex.com) and retrieve the Modified date again for that list item.

    3) If the date from #1 does not match the date from #2, then someone has modified the item and you can throw up a message to the user.

    Another downfall of using any kind of jQuery approach is that it won't work if the a user makes changes in the DataSheet view.

    I would suggest implementing an Event Receiver if at all possible using a similar method as this will also prevent saves from the datasheet.

     

    All of that said... if you can enforce rules where users's MUST save or cancel an edit, a super simple approach would be:

    1) create a checkbox field called "Editing"

    2) When a user goes to the edit form, execute a script in a CEWP on the page that:

    3) checks the value of "Editing" if it is not set, set it immediately and save the item immediately.

    4) if "Editing" is already set throw an error saying a user is already editing this form.

    5) On save for cancel, clear the value of "Editing"

     

    Hope that helps..

    Mark

    • Marked as answer by DavidLewis27 Friday, June 10, 2011 6:20 PM
    Wednesday, May 11, 2011 3:43 PM

All replies

  • Hey David,

    What happens if a user opens up a page to edit the list item and then decides to just close their browser? How will you know it's not being edited anymore since the user didn't save or cancel their action? I think that is going to be your biggest issue using any straight jQuery approach to check to see if "someone else is editing". 

    I'm sure there are other options, but a quick and dirty approach would be:

    1) When a user goes to edit an item save the modified date in a variable.

    2) When the user clicks to save the item, BEFORE THE SAVE do a jQuery call using SPServices (http://spservices.codeplex.com) and retrieve the Modified date again for that list item.

    3) If the date from #1 does not match the date from #2, then someone has modified the item and you can throw up a message to the user.

    Another downfall of using any kind of jQuery approach is that it won't work if the a user makes changes in the DataSheet view.

    I would suggest implementing an Event Receiver if at all possible using a similar method as this will also prevent saves from the datasheet.

     

    All of that said... if you can enforce rules where users's MUST save or cancel an edit, a super simple approach would be:

    1) create a checkbox field called "Editing"

    2) When a user goes to the edit form, execute a script in a CEWP on the page that:

    3) checks the value of "Editing" if it is not set, set it immediately and save the item immediately.

    4) if "Editing" is already set throw an error saying a user is already editing this form.

    5) On save for cancel, clear the value of "Editing"

     

    Hope that helps..

    Mark

    • Marked as answer by DavidLewis27 Friday, June 10, 2011 6:20 PM
    Wednesday, May 11, 2011 3:43 PM
  • Hi David,

    You may want to take advantage of version control (major and minor versioning) to control concurrent editing!

    Here is the link for more details:
    http://office.microsoft.com/en-gb/windows-sharepoint-services-help/enable-and-configure-versioning-for-a-list-or-library-HA010021494.aspx?CTT=3

    hth,


    Chirag Patel, MCTS
    @techChirag
    techChirag.com
    • Proposed as answer by Parvez Akkas Saturday, May 14, 2011 3:11 PM
    • Marked as answer by David HM Monday, May 16, 2011 10:11 AM
    • Unmarked as answer by DavidLewis27 Friday, June 10, 2011 6:20 PM
    Thursday, May 12, 2011 9:38 PM
  • You can use versioning to keep track of changes as techChirag suggested.

    I don't think there's really much you can do from the front end. Concurrence item editing comes down to seconds/milliseconds. Regardless of who "clicked" OK first, ultimately whichever request comes to the database first, will take the action and lock that entry from editing further and when that is done, the lock is removed. I believe SharePoint's database is does this already.

     


    Pman
    http://www.pmansLab.com/
    Saturday, May 14, 2011 3:10 PM