Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent SharePoint list item deletion

How can I prevent users from deleting sharepoint task list item? Should i override the ItemDeleting event or is there any other site level options available to achieve the same?

like image 439
Shankar Avatar asked Apr 04 '11 12:04

Shankar


2 Answers

You could also set up a custom permission level out of the box.

  1. Navigate to your Site Collection (if you're in a subsite, you can go to Site Actions -> Site Settings -> Go to top level site settings)
  2. Site Actions -> Site Settings -> Advanced permissions
  3. Click Settings -> Permission Levels
  4. Click Add a permission level

I would recommend using the existing "Contribute" permission level as a guide and just uncheck the "Delete Items" list permission. Then, you can give your users that permission to the list.

like image 73
Kit Menke Avatar answered Oct 04 '22 08:10

Kit Menke


You can use List Item Event Receiver, ItemDeleting method:

public override void ItemDeleting(SPItemEventProperties properties)
{
    properties.ErrorMessage = "User don't have permission";
    properties.Cancel = true;
}
like image 27
vvk Avatar answered Oct 04 '22 06:10

vvk