Monday, September 29, 2014

Remove and Add Title column from Content Types in SharePoint 2010

I was working on content types today and realized that SharePoint 2010 is forcing me to use Title Column which I didn't require. I wanted to remove this column but unlike other columns I added, I could not see Remove button.

Custom Column in Content Type with Remove Button
 Content Type Title Column without Remove Button
I googled for it and got to a post (just like you did) to be able to remove Title Column.

Steps to perform
1. Open SharePoint 2010 Management Shell by click Start > All Programs > Microsoft SharePoint 2010 Products > SharePoint 2010 Management Shell right click and Run as Administrator
2. Run the following script
$web = Geb-SPWeb http://YOURPORTAL
$ct = $web.ContentTypes["YOUR CONTENT TYPE"] 
$spFieldLink = New-Object Microsoft.SharePoint.SPFieldLink ($web.Fields["Title"])
$ct.FieldLinks.Delete($spFieldLink.Id)
$ct.Update()
$web.Dispose()

Note: Always test the script on Staging / Test environment before running it on your Production environment.
You also need to understand that removing this column will not remove it from any of the lists/libraries that are using this column.

A little later I realized that I wanted this column back so I ran the following to get it back.

$web = Geb-SPWeb http://YOURPORTAL
$ct = $web.ContentTypes["YOUR CONTENT TYPE"] 
$spFieldLink = New-Object Microsoft.SharePoint.SPFieldLink ($web.Fields["Title"])
$ct.FieldLinks.Add($spFieldLink)
$ct.Update()
$web.Dispose()


Thank you Phil Childs for pointing me to right direction