In SharePoint 2013, how can I stop users from deleting a item from one of many lists on many sites.

We can't change permissions level because it's a enterprise level product and dealing with permissions for such tasks would take ages and will create a lot of mess , I am thinking about using event receiver to stop user from deleting item but how ?

public override void ItemDeleting(SPItemEventProperties properties)
    properties. // how to cancel ??
  • 3
    So you plan to introduce server side code when an ootb approach works just fine for this? – Eric Alexander May 14 '15 at 12:25
  • @EricAlexander we can't change permission levels, what other option do we have here - other then ER? – Mathematics May 14 '15 at 12:47
  • 1
    "I am not going to change permissions level" is a lot different than we can't. The better option to me is creating a custom contribute permission with delete items unchecked and applying that to the group than building server side code to do it regardless of what the requirement is. Just because you can code out a solution to do it does not mean that is the proper approach. ER would be the only approach, but would be the wrong implementation IMHO. – Eric Alexander May 14 '15 at 12:55
  • updated my question#, 1 site 5 lists (template - deployed hundred times), only don't want user to be able to delete items from 1 list, changing permission levels won't work here btw – Mathematics May 14 '15 at 12:57
properties.Status = SPEventReceiverStatus.CancelNoError; OR .CancelWithError

The following code snippet will prevent item deletion and also notify the user of what happened

public override void ItemDeleting(SPItemEventProperties properties)
    properties.Status = SPEventReceiverStatus.CancelWithError;
    properties.ErrorMessage = "This item cannot be deleted; Contact your administrator";


The above snippet generates the following error when a user tries to delete an item in a list where the event receiver is active: enter link description here


How to create the event reciver, please follow this: Creating a simple Event Receiver in SharePoint 2013


You can use below ItemDeleting method:

public override void ItemDeleting(SPItemEventProperties properties)
    properties.ErrorMessage = "Your Message goes here!";
    properties.Cancel = true;


As above method is deprecated you can use below method, using Status property.

SPEventPropertiesBase.Status property

public override void ItemDeleting(SPItemEventProperties properties) {
    properties.Status = SPEventReceiverStatus.CancelNoError;

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.