How to Prevent SharePoint List or Columns from Deletion?

Scenario: We have a configuration list being used by a custom SharePoint application, and we don’t want to let the users 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 Disable Delete on SharePoint List or Library:

#Get the Web
$web = Get-SPWeb "https://sharepoint.crescent.com/sites/pmo"

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

#Set the "AllowDeletion" property
$List.AllowDeletion=$false
$List.Update()

“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("https://sharepoint.crescent.com/sites/pmo"))
{
  using(SPWeb web = site.OpenWeb())
   {
       SPList list = web.Lists["Design Documents];
       list.AllowDeletion = false;
       list.Update();
   }
}

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:

PowerShell script to Disable Delete on SharePoint List or Library

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 "https://sharepoint.crescent.com/sites/pmo"

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

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

#Disable Delete
$column.AllowDeletion = $false
$column.Update()
 
$web.Dispose()

Output:

sharepoint 2010 unable to delete list column

Now, the reverse: Delete Button Missing in SharePoint Column? Here is How to Delete them.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

3 thoughts on “How to Prevent SharePoint List or Columns from Deletion?

  • I am just a shrepoint list administrator in my company. Can I do this type of configuration without admin privileges for only my sharepoint list?

    Reply
  • hi
    Can i have event receiver to prevent deletion of column for a list ?

    -Jiniv
    jinivthakkar@gmail.com

    Reply
    • Yes! from SharePoint 2010, We’ve FieldDeleting Event in List event receivers. Can utilize that too!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *