Enterprise Solutions Part 1: Content Type Syndication

This is the first blog in my little series on SharePoint 2010 enterprise solutions. The series has the following topics which I keep running into while working on various SharePoint projects:

  1. Content Type Syndication (this post)
  2. Document Sets (coming soon)
  3. External Content Types (coming soon)
  4. Taxonomies (coming soon)
  5. Metadata Navigation (coming soon)
  6. Web Service Delegation (coming soon)

Content type syndication is one of the great new features in SharePoint 2010. It solves the problem of distributing content types across site collection boundaries and keeps your custom content types in sync where ever these are used. It consists of a content type hub site where the syndicated content types are published. Other site collection can subscribe to the content type hub site. SharePoint timer jobs (scheduled to run every 15 minutes per default) do the actual publishing of the content types to the subscriber site collections. Alternatively, when a new site collection is being created, the published content types are instantly available on it.

I will cover the following aspects of content type syndication in this blog post:

  1. Limitations
  2. Setting it up
  3. Auto-publishing content types
  4. Updating content types

1. Limitations

Lookup fields (single and multi-value) are not supported by content type syndication. This makes good sense because lookup fields work within site collection scope. By design, a lookup field cannot reference a list in another site collection. Content type syndication is designed to work across site collection boundaries and therefore it would make no sense to support lookup columns. If you need lookup functionality and want to use content type syndication you must switch to use taxonomies (Managed Metadata, see Part 4 of this series).

You might run into an issue when syndicating custom document set content types. When creating a document set based on your custom content  type you get the error message: “The content type ‘…’ is read-only.”. The error is triggered by the ProvisionCTEventReceivers method in the SharePoint DocumentSet class when the code is adding the ItemAdded and ItemUpdated event receiver. Published content types are by design read-only in the subscriber site collections. Because SharePoint tries to add the two mentioned event receivers to the read-only content type you get the error. The solution is to add the event receivers to your custom content type. For details on how to do this see Part 2 post of this series.

2. Setting it up

The  following steps are necessary to set content type syndication up:

  1. Create site collection for the hub
  2. Configure Managed Metadata service application to point to hub site
  3. Create a subscriber site collection

2.1 Create Hub Site Collection

Create a site collection that is used for nothing else but the content type hub. You do not want anything else in this site collection: No content pages, no custom lists or libraries. This is to make sure that it is always possible to update the content types in the hub site collection easily. When there are no lists or lists items provisioned in a site collection based on a custom content type it can simply be updated by re-activating the feature that deployed it. There can only be one content type hub per Managed Metadata service application. So it is up to you where you want to put it. You can create an entire web application where you place the hub in the root site collection of it, a host header site collection or a hub site collection under a managed path of one of the existing web applications such as http://…/sites/cthub. The disadvantage of creating an entire web application is that it allocates server resources and there it is not recommended to have more than ten web applications per farm. In the example here I chose to create a separate web application for the content type hub.

Because I do not want any content on the hub site collection I simply create a blank site as shown below.

Post214-1

Next, configure the hub site collection:

  • Activate the built-in site collection scoped feature ‘Content Type Syndication Hub’ (Feature ID: 9a447926-5937-44cb-857a-d3829301c73b)
    Powershell: Enable-SPFeature -Identity 9a447926-5937-44cb-857a-d3829301c73b -Url http://cthub
  • Activate the built-in, hidden site collection scoped feature ‘TaxonomyFieldAdded’ (Feature ID: 73EF14B1-13A9-416b-A9B5-ECECA2B0604C)
    Powershell: Enable-SPFeature -Identity 73EF14B1-13A9-416b-A9B5-ECECA2B0604C -Url http://cthub
  • Activate your custom content type feature (or create the content types manually if you want)
  • Publish the syndicated content types

The TaxonomyFieldAdded feature is included in most of the SharePoint out-of-the-box site definitions but not in the blank site that I created. When this feature is not activated you will be missing the ‘Content type publishing’ link under Site Settings / Site Collection Administration.

Post214-2

The ‘Content type publishing’ dialog is shown below. It is though most useful on the subscriber site collections as it shows you which content types currently are syndicated. This is the number one trouble-shooting tool. Also it shows you the URL of the content type hub. So you can easily check whether the configuration is ok. In our case this simply points to http://cthub.

Post214-3

The final step is to create a content type and publish it. Go to the content type via Site Settings / Content Types, select the content type you want to publish and than click on the ‘Manage publishing for this content type’ link. If the content type is not yet published the radio button ‘Publish’ is selected. Click ok to actually publish it. For an already published content type you can choose between unpublish and republish.

Post214-4

2.2 Point to Hub

To make use of the content type hub we created in the previous step it must be configured. The Managed Metadata service application has the setting for it. You can configure exactly one content type hub per Managed Metadata service application. The configuration can be done via Central Administration or PowerShell. To set it up, do the following:

  1. Go to Central Administration / Application Management / Manage Service Applications
  2. Select the Managed Metadata Service and click on the Properties button in the ribbon
  3. Scroll to the bottom of the modal pop-up and enter the URL for the content type hub site as well as check the ‘Report syndication import errors…’ check-box

Post214-6

As you can see on the screen shot above there is no way to change the URL through the UI once it has been configured. That is a bit impractical but you can fall-back to PowerShell to set it:

 

2.3 Create a Subscriber Site Collection

Create a new site collection in a different web application and the syndicated content type published earlier is immediately available. You can check this via Site Settings / Content type publishing in the subscriber site collection. All subscribed content types are listed there. In our case it is only the ‘Bike’ content type I created in step 2.1.

Post214-5

When working with feature deployed content types you also have to activate the content type feature (containing the syndicated content types) in the subscriber site collections. This is safe to do and you can verify that the content types really are syndicated via the Site Settings / Content type publishing function as well as checking that the content types are marked as ‘Read-only’.

3. Auto-publishing Content Types

I would like my content types to be published automatically. In an enterprise solution with many content types it would be tedious to have to click three times for each content type to publish it. So I created a feature with a feature receiver to do it. The code is quite generic as it reads the content types to publish from the feature properties which enables you to reuse the helper class in other projects.

 

Here is the feature receiver of the publish content types feature:

 

Here are the feature properties of the publish content types feature:

 

4. Updating Content Types

Once the setup is completed you can begin to make use of the content type syndication and update some content types. To get updates published to subscriber site collections the following steps are necessary:

  1. Update the content type:
    1. Either directly on the hub site via SharePoint UI (if the content type was manually created) or
    2. Change in XML, deploy the WSP and re-activate the content type feature on the hub site
  2. Verify that the content types are updated correctly on the hub site collection (only necessary for feature deployed content types)
  3. Wait for the syndication SharePoint timer jobs to execute (every 15 minutes) or start these manually via Central Administration
  4. Verify that the content types were updated as expected one of the subscribe site collection

The screen-shot below shows the content type syndication SharePoint timer jobs from my environment from Central Administration / Monitoring / Review Job Definitions. There is one for the hub and one timer job per subscriber web application. To start the timer jobs manually you can simply click on each of them and click the ‘Run Now’ button. Than you can check the timer job history page on Central Administration to see when the jobs are done.

Post214-7

Leave a Reply

Your email address will not be published. Required fields are marked *