onsdag 30 maj 2012

Why will the content type associated to the Pages library update?

This was a simple problem that a college had. When changes were made to the content type it did not push through to the "Pages" library.

First we create the new site column Content_HU

<Field ID="{801797DA-B4A3-45F3-A177-4D405C85C2D9}"
      Name="Content_HU"
      DisplayName="$Resources:Company.Intranet.Resources,column_Content_HU;"
      Type="Note"
      Required="False"
      Group="Company Intranet"/>

Add it to content type

<FieldRef ID="{801797DA-B4A3-45F3-A177-4D405C85C2D9}" Name="Content_HU" />

Added richtextfield (or PublishingWebControls:RichHtmlField if we use the html type) for Content_HU in page layout

<SharePointWebControls:RichTextField  ID="RichTextField1" FieldName="Content_HU" runat="server"/>

Now when we check the associated content type in Pages library of site test (publishing site under site collection) we can see that

Parent Company.Intranet.ContentTypes.NewsPage3
English Content Multiple lines of text Optional
Hungarian Content Multiple lines of text Optional
Swedish Content Multiple lines of text Optional

Child Company.Intranet.ContentTypes.NewsPage3
English Content Multiple lines of text Optional Company.Intranet.ContentTypes.NewsPage
Swedish Content Multiple lines of text Optional Company.Intranet.ContentTypes.NewsPage

As we can see, the changes have not been pushed out to the library. This is because the content type associated with the library is a copy of the site content type, and since it made the copy before the new one existed nothing is pushed through.

Now if I make another publishing site test2 under the site collection it will inherit from the latest version of the content type associated with the page layot. And thus letting me use it



If we really need to push updates like this we should use upgrade actions. 

<Feature xmlns="http://schemas.microsoft.com/sharepoint/">
  <UpgradeActions>
    <VersionRange EndVersion ="2.0.0.0">
      <AddContentTypeField ContentTypeId="0x0101002b0e208ace0a4b7e83e706b19f32cab9"
                           FieldId="{ccbcd479-94c9-4f3a-95c4-58897da434fe}"
                           PushDown="True"/>
    </VersionRange>
  </UpgradeActions>
</Feature>


This guy has a blogpost about it that pretty much shows it, otherwise the rest of the article the above snippet is from is findable on MSDN. But of course people are still having trouble with actually getting this to work, this is when we turn to questions on one of the stackexchange sites (like this one).

onsdag 9 maj 2012

A collection of nuggets

Nuggets

Nuggets are posts with links I stumble across and want to remember in the future, either for reference or because they might provide input for longer ramblings. Now I don't know if this is something blogworthy or not, if you stumble across this and consider it an idiotic idea, let me know in the comments.

Deployment

Jan Steenbeek explains how to trick SharePoint into deploying solutions to target a specific web application instead of making it globally available in this article. Good tip. Combine it with these simple powershell deployment scripts from Softartisans and go deploy.

Kill the mobile interface

SharePoint Joel has figured out that noone uses WAP anymore and urges us to "Kill SharePoint 2010 Mobile Interface". I couldn't agree more.

Dependency injection

Dependency Injection and inversion of control is something that confused me for a long time. James Shore has an introductory article on the subject where he says: "Dependency injection means giving an object its instance variables. Really. That's it.". And in it's simplest form, this is actually true.

At the end of the article he points to further reading that goes into depth on the subject. This is something that is widely used in the .NET community and something that I will come back to in a blog entry in the future.

Spsdatagenerator

I have been using the datagrid to mass input test data when testing out solutions. Now I don't have to do this anymore thanks to the spsdatagenerator project on codeplex. Hurrah!