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:
"Delete this document library" or "Delete this list" link will go hidden under list settings!
We can use the C# code as well to disable delete option on SharePoint list and libraries:
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:
Unable to delete list column in SharePoint 2010? Her is how to delete SharePoint list column programmatically with PowerShell
In some cases, columns added through "Add existing columns" doesn't provide the option to delete! To make them deletable, just revert these two propertis: AllowDeletion & Sealed.
![]()
Its also possible to make the field as sealed as well as non-deletable, so that the field look like:
SharePoint Manager tool can be used to set these properties. Just navigate to the site, list or library and set the "AllowDeletion" property to false, save the changes. This hides delete option in SharePoint list.![sharepoint list disable delete sharepoint list disable delete]()
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 "http://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!
We can use the C# code as well to disable delete option on SharePoint list and libraries:
using(SPSite site = new SPSite("http://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:
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 "http://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:
Unable to delete list column in SharePoint 2010? Her is how to delete SharePoint list column programmatically with PowerShell
In some cases, columns added through "Add existing columns" doesn't provide the option to delete! To make them deletable, just revert these two propertis: AllowDeletion & Sealed.
#Get the Web $web = Get-SPWeb "http://sharepoint.crescent.com/sites/pmo" #Get the List $list = $web.Lists["Design Documents"] #Get the column $column = $list.Fields["Category"] #Disable Delete $column.AllowDeletion = $true $column.Sealed = $false $column.Update() #To delete a SharePoint list column in PowerShell, use: $column.Delete() $web.Dispose()We can also make fields to "Sealed, So that nobody can change the field settings.

Its also possible to make the field as sealed as well as non-deletable, so that the field look like:
SharePoint Manager tool can be used to set these properties. Just navigate to the site, list or library and set the "AllowDeletion" property to false, save the changes. This hides delete option in SharePoint list.
