Monday, December 10, 2007

Who are you Inherited From?

While working on a new SharePoint project recently, the issue of how best to package the list instances, content types, and site columns to deploy them to a production site cam up. The first time we tried to use Features and Solutions to deploy SharePoint lists, let's just say, was kind of a disaster. We ended up destroying all of the built-in base content types and having to reinstall MOSS on the development server.

This time around I was determined to figure out how to use Features and Solutions to deploy these items. In the next few posts I will describe how I used new tools available to ease this development and the issues I cam across while using Features.

The first problem that I attempted to solve was the inheritance of content types. In our project we had a Request content type that inherits from the base event type. This Request type was then going to be inherited by other content types that I was going to develop and then eventually applied to a list. The first problem I had was the lack of good documentation on the MSDN about content types and how to inherit them. I started to look at some blogs and it seemed that everyone was using a different method and having it work.

I eventually settled on a system that worked. It began by realizing that there are two types of content types - site content types and list content types. Site content types are created at the site level and can be applied to multiple list instances. List content types are an instance of a site content type that is applied to a specific list. This allows you to set a column as hidden or change the order of the columns for a specific list without modifying the site content type.

Once I figured this out the documentation made a little more sense. I ended up creating the Request content type inherit from the base event content type through the "00" + hexadecimal GUID inheritance method. So to inherit from event the content type would look like 0x010200AB1294....continue 32 GUID digits. The ox represents the system type, the 01 the base item type and the 02 the base event type. You then divide your GUID with "00" as a separator. You then append a GUID to make a unique content type identifier.

For the content types that inherit from the Request type you can use the "A0" two hexadecimal digit method for content type inheritance by taking your content type ID for the Request type and appending two hexadecimal digits to it.

This worked well for me in my inheritance project.

To create a list content type for a list instance, I then took my content type ID and using the "00" + hexadecimal GUID method created a unique ID for the list version of the content type.

Another interesting thing with content types and list content types in list instances is that you need to include all of the fields in the list definition as well as the content type in order for the columns to show up in the list instance.

Some of the links that I used for for content types are:

http://msdn2.microsoft.com/en-us/library/aa543822.aspx

http://msdn2.microsoft.com/en-us/library/ms479905.aspx

This second link is the generic link about content types. There is a lot of information here about content types, it just isn't as thorough as it could be.

In the next post I will discuss some new tools to speed development of Features and Solutions.

Labels: , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home