Wednesday, February 2, 2011

How to apply changes to fields in an existing page layout content type which is in use.

Seems to be very straight forward to do, but I came across lot of trouble doing this and thought it is worth to share it with you all.

 

I had a multi lookup field name topics in my page layout content type which retrieve data from a share point list.

Initially my lookup field allow only 255 characters. So the problem was when  the number of topics are large, if I try to add more topics it will give an error saying

 

This field can have no more than 255 characters.

 

So as a workaround for that I add the lookup field attribute UnlimitedLengthInDocumentLibrary=”true” and redeploy it.

But the error was still there.

Then I delete all the pages that were referring to my page layout and then delete the page layout and deactivate the content type.

Then I reactivate the content type and restore the page layout and pages. But the error was still there.

 

Workaround

Here is the solution that I come up with. Even though you deactivate and activate the content type , somehow it reference to the old field definition.

In order to overcome this

1.      go to the site content types-> select the relevant content type

2.       select the field on which you did  the modification

3.       click on edit site column

4.       then do nothing. Yes do nothing and click ok.

5.       You are done!

 

Tuesday, February 1, 2011

How to Remove a sealed column in SharePoint 2010 using powershell or sharepoint manager.

Last week when I was working with a sharepoint list, I needed to add a page content field for testing purposes. After  sometime I wanted to remove it.
Strangely I couldn’t do that. Typically when you want to remove a field to a list in sharepoint web frontend, you can easily do that by
1.       go to the list settings
2.       click on particular field in the list
3.       then click on the remove button in the left hand side. (near OK,Cancel) button.

But this time I couldn’t do that.  After spending some time and thanks for my mate Diluk, I figured it out what should be done.
When you add a page content field it will created as sealed column and by default sharepoint doesn’t allow to delete sealed columns.

For that we can use either Sharepoint powershell commands or Sharepoint Manager.

Using Powershell Commands
The following steps provide the way to remove it using powershell commands.
1.       Run SharePoint 2010 Management Shell as administrator. SharePoint 2010 Management Shell can be found under the Microsoft SharePoint 2010 Products in start menu.
2.       Connect to the site
$site
$web = $site.RootWeb
$web
$list = $web.Lists["topics"]
$list
$field = $list.Fields["Page Content"]
$field
After this you need to  set the field properties “Allowdeletion” to true and “Sealed” to false

$field.Allowdeletion = $true
$field.Sealed = $false

Then you can delete the field

$field.Delete()

Make sure to update the list after deletion

$list.Update()

Now you are done!

Using Sharepoint Manager Tool

1.       Run the Sharepoint Manager Tool in your machine (you can download it here)
2.       Go to Content Service -> Web Applications -> Your Site -> Site Collection -> Your Site Collection Url -> Fields
3.       Expand the Field list and select the relevant field
4.       On the right hand side pane you can see the field properties.
5.       Find AllowDeletion property and set it to true.
6.       Find Sealed property and set it to false.
7.       Then right click on the field on the left pane and click Delete.
8.       That’s it!