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).

Inga kommentarer:

Skicka en kommentar