Monday, June 17, 2013

How to Prevent SharePoint List or Columns from Deletion

Scenario: We've a configuration list being used by a custom SharePoint application and we don't want to let the users to delete the configuration list in SharePoint. So how to prevent delete in SharePoint list?

The idea is: Set the "AllowDeletion" property of the SharePoint list or Library to false. These properties can be set programmatically using object mode code C# or PowerShell.

PowerShell script to make SharePoint List/Library deletable:

#Get the Web
$web = Get-SPWeb ""

#Get the List
$list = $web.Lists["Design Documents"]

#Set the "AllowDeletion" property

"Delete this document library" or "Delete this list" link will go hidden under list settings!
sharepoint 2010 delete this list option missing

We can use the C# code as well to disable delete option on SharePoint list and libraries:
using(SPSite site = new SPSite(""))
  using(SPWeb web = site.OpenWeb())
       SPList list = web.Lists["Design Documents];
       list.AllowDeletion = false;

Same trick applies to SharePoint list columns as well. Sett the field's "AllowDeletion" property to false to prevent the field from deletion. Here is an example: Typical SharePoint list columns will look like:
Lets prevent the column from deletion by setting "AllowDeletion" property to false.

PowerShell script to disable delete on list columns:
#Get the Web
$web = Get-SPWeb ""

#Get the List
$list = $web.Lists["Design Documents"]

#Get the column
$column = $list.Fields["Category"]

#Disable Delete
$column.AllowDeletion = $false
sharepoint 2010 unable to delete list column
Now, the reverse: Delete Button Missing in SharePoint Column? Here is How to Delete them.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:


  1. hi
    Can i have event receiver to prevent deletion of column for a list ?


    1. Yes! from SharePoint 2010, We've FieldDeleting Event in List event receivers. Can utilize that too!


Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...