Thursday, May 10, 2012

"I cannot delete this column from my list??" - Well that must be a SharePoint 2010 Peristent column

If  you are viewing this blog post I assume you have not had a very good day at work today! Here's a look at what happened to me -

I recently ran into a problem where one of my users added a site column called "Target Folder" to their SharePoint list and later realized that that column was not required. So the user wanted to delete the "Target Folder" column. That is the most basic SharePoint task that is there to be done and so I wondered that why is this user coming to me for something so trivial.

Alas! Everything in SharePoint is not what it seems. I went to the list settings clicked on the column and I could not find the delete button in fact I could not find any means to edit that column. What happened here? I checked some other columns (Had my farm gone crazy?) No! Every other column in that list (or for that matter in the site) seemed absolutely fine.

After a few hours of digging here and there I turned to Master Google and I was enlightened!

There are a set of site columns which are Persistent site columns and once added to a list these columns cannot be modified or deleted (through the SharePoint UI). Also, if you add these site columns to a custom site content type you will not be able to delete the site content type as well. On attempting to delete the site content type you will get an error stating - "The content type is in use and cannot be deleted" even though you have not used the content type anywhere.

Here is a list of site columns which are persistent:
  1. Active
  2. Aliases
  3. Article Date
  4. Byline
  5. Contact
  6. Contact E-Mail Address
  7. Contact Name
  8. Contact Picture
  9. Custom Router
  10. Image Caption
  11. Page Content
  12. Page Icon
  13. Page Image
  14. Priority
  15. Properties used in Conditions
  16. Property for Automatic Folder Creation
  17. Rollup Image
  18. Route To External Location
  19. Rule Name
  20. Scheduling End Date
  21. Scheduling Start Date
  22. Submission Content Type
  23. Summary Links
  24. Summary Links 2
  25. Target Audiences
  26. Target Folder
  27. Target Library
  28. Target Path
Be very sure before adding these columns to your list or content type.

To delete these site columns from your list you will need to do so by using PowerShell commands as follows:

$web = Get-SPWeb (Your site URL)
$list = $web.Lists[(Your List Name)]
$field = $list.Fields[(Your Column Name)]
$field.AllowDeletion = “true”
$field.Sealed = “false”
$field.Delete()
$list.Update()
$web.Dispose()

And.. I hope the rest of your day (if left) is nice!

 - Huzefa Mala

No comments:

Post a Comment