views:

155

answers:

2

We have an issue with rolling out content types with features. How does one roll them out to the SharePoint farm and update the database at the same time. Right now, we cannot figure it out. Is there something that has to be done custom?

A: 

By "update the database" I would assume that you mean your custom database, not any of the SharePoint databases?

Deign your database so that you will have some sort of mechanism to store the version. In its most simple form, a configuration table with a version row/column would be sufficient. You can in the feature activated event, place code that checks the version of your database and, if necessary, performs any custom T-SQL scripts that updates your database.

Magnus Johansson
A: 

Content types can be confusing to deploy. Once you deployed the content type by a feature and someone is using this content type (I.e a Sharepoint list, document, page layout etc) you CANNOT update the content type by redeploying the feature. This is by design. When a list adds a content type it makes a copy of the content type in the site collection.

There are two ways to solve this:

  1. Update the content type in GUI and check "update all child content types"
  2. Create a new feature "update content type x feature". Add a event handler to the feature activation and update the content type in the site collection by applying the contentType.update(true) method. To verify that all the child content types are updated create a SPQuery object with an beginswith parameter to the content type id.
Tomso