0

I have a list on SharePoint Online, where I need to make sure that only one person can edit a list item at a time. For example, if Person A edits a list item, it MUST be clear to everyone else working, that Person A is working on this list item and no one else should be able to edit this item.

As this is a list I am unable to turn the check in/check out feature on like I could if it was a document library.

Any suggestions would be much appreciated.

Edit

I have tried adding the below code to both the NewForm.aspx and Edit Form.aspx pages but it doesn't seem to work:

<script type="text/javascript" src="/%20sites/Devsite%20/SPServices.0.7.2.js"></script><script type="text/javascript" src="/sites/Devsite/jqueryv1.8.3.js"></script><script type="text/javascript">  
var loggedInUser="";  
 $(document).ready(function(){   

     document.getElementById('CheckedOutTo_8eb26269-8497-4b14-9785-ca206415c404_$TextField').disabled = true;  
     var checkInOutValue=$('[name="CheckInOut_9c53da6b-28f9-4200-9823-36913cf0e610_$RadioButtonChoiceField1"]:radio:checked').val();  
     var checkedOutToValue=document.getElementById('CheckedOutTo_8eb26269-8497-4b14-9785-ca206415c404_$TextField').value;  
     var thisUsersValues = $().SPServices.SPGetCurrentUser({  
         fieldNames: ["Name", "Title"],  
         debug: false  
     });  
     loggedInUser=thisUsersValues.Title;  
     if(checkInOutValue=="Check-Out")  
     {  
         if(loggedInUser!=checkedOutToValue)  
         {  
//if the user doesn’t belong to the CheckedOutTo field then don’t allow the //user to edit an item .instead redirect the user to allitems.aspx page  
             $('[name="CheckInOut_9c53da6b-28f9-4200-9823-36913cf0e610_$RadioButtonChoiceField"]').prop('disabled',true);  
             alert("This item is checked out to: "+checkedOutToValue+". You will not be able to edit this item.");  
             window.location.href="/DealingFXTradeSlip/Lists/FXTradeSlip/Dealers.aspx";  
         }  
     }  
     radioButtonChange();  

 });   

 function radioButtonChange()  
 {  

     $('#CheckInOut_9c53da6b-28f9-4200-9823-36913cf0e610_ChoiceRadioTable').change(  
         function(){               
             var checkInOutValue=$('[name="CheckInOut_9c53da6b-28f9-4200-9823-36913cf0e610_$RadioButtonChoiceField"]:radio:checked').val();  
     if(checkInOutValue=="Check-Out")  
     {  
         document.getElementById('CheckedOutTo_8eb26269-8497-4b14-9785-ca206415c404_$TextField').value=loggedInUser;  
     }  
     else if(checkInOutValue=="Check-In")  
     {  
        document.getElementById('CheckedOutTo_8eb26269-8497-4b14-9785-ca206415c404_$TextField').value="";       
     }  
}); 
</script>​​
2
  • Please refer this link, c-sharpcorner.com/UploadFile/0e18a8/… May 26, 2020 at 11:07
  • Thanks Karthik. I have followed these instructions and changed the field ID's to match mine but unfortunately it isn't working. I have updated my main post with the code I have added to both the New and Edit form pages.
    – user69394
    May 26, 2020 at 13:15

1 Answer 1

0

There is no OOTB method to block editing a list item when another user already edits. You need to do Custom code or JQuery/JSLink.

1

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.