All about Microsoft Office SharePoint Server Content Type – Part 4

In the part 1 of the article we covered

  • What is a content type
  • How content types work
  • In the part 2 of the article we covered

  • Extending content types
  • Attaching workflows to a content type
  • Attaching event handlers to a content type
  • In the part 3 of the article we will cover

  • How to create a Content Type programmatically using SharePoint object model
  • Significance of Content Type ID
  • Creating Content Types using Visual Studio Extensions for WSS
  • Deployment of Content Types as Features
  • In this part 4 (final part) of the article we will cover

    • Solution Package Editing in VS 2008 / WSP view
    • Adding content type to a list definition


    Solution Package Editing in VS 2008 / WSP view:

    Using Visual Studio 2008 and VSeWSS 1.2 you can create SharePoint projects. It also provides a developer friendly WSP view / Solution Package Editing option. Lets run through this option to see how it helps developers to quickly create the WSP and and the Deployment Package.

    Pre Requisites:

    VS 2008

    VSeWSS 1.2

    • Start up your Visual Studio 2008.
    • File->New->Project choose SharePoint under Visual C# project types
    • Select ‘Empty’ project.
    • Right Click the project –>Add->New Item choose SharePoint under Visual C# categories and select ‘Content Type’
    • Give it a name for example ‘MyNewContentType’
    • Choose ‘Item’ as the base content type.
    • Edit the ‘MyNewContentType.xml’ and un comment the Field schema definition (We are going to use the default fields generated for this demo)
    • <?xml version="1.0" encoding="utf-8"?>
      <Elements Id="ca5ae715-cdb6-4454-b581-a5c3b968fc7c"
        <ContentType ID="0x01000cd55cdd7f634cc6aa237f152e1a1875"
                     Description="Developing Content Type"
              Name="MyNewContentTypeField" />
        <Field ID="{2986f56e-9b87-426a-b7ee-989758c88533}"
               DisplayName="MyNewContentType Field"
               Sealed="FALSE" />
    • In the Solution Explorer window you will find a tab ‘WSP View’


    • Let us look at this TAB and see what we got there. If it does not show the contents hit the ‘Refresh’ button


    • This has the virtual view of the solution package our VSeWSS is putting together for us.
    • Here you can edit the feature.xml and update the name, display properties.
    • This gives more control to the developers and also it provides a easy way to deploy to the local SharePoint box for testing
    • Right Click the project select properties and choose Debug tab. Set the URL to the desired Site Collection where the feature needs to be deployed.


    • Now you can either press F5 or Right Click Project and Select ‘Deploy’ option.
    • This will create the deployment package, deploy the solution and activate the feature for the selected site collection.

    Adding a Content Type to a List Definition:

    In this walk through I am going to create a new List Definition and add the ‘MyDerivedContentType’ that I created earlier (refer to Part – 3)

    • Start up your Visual Studio 2008.
    • File->New->Project choose SharePoint under Visual C# project types
    • Select ‘List Definition’


    • Once selected it will create a project structure similar to the one shown below


    • Open the Schema.xml. Insert the ContentTypeRef node inside the ContentTypes tag

    <ContentTypeRef ID=”0x010044AFF40E174C4F7D89861FF89CEE1D15003824D8E586F44E54AC7049578A0100E5“/>

      <ContentTypeRef ID="0x01">
        <Folder TargetName="Item"/>
      <ContentTypeRef ID="0x0120"/>
    • The tricky thing is we have to now add all the fields that we want as part of this list instance of the ContentType. If we do not add the fields and update the views we will not get those columns even though it is part of the ContentType. I think it is kept this way in order to have the flexibility of creating an instance of the existing content type with the desired columns.
    • Under the Fields node add all the Fields that are part of the ‘MyDerivedContentType’ including the one in the base content type,
          <Field ID="{71ED4BE5-B83F-47e4-866E-08D226709522}"
           Name="Project Status"
           DisplayName="Project Status"
           Group="Custom Columns"
              <CHOICE>Not Started</CHOICE>
              <CHOICE>In Progress</CHOICE>
          <Field ID="{5623b931-2e9e-4dc6-81b6-c8a151f37418}"
            Name="Team Member"
            DisplayName="Team Member"
            Group="Custom Columns"
          <Field ID="{9b39033a-4f1c-4a0f-9deb-73fecdbc3b5d}"
            Name="Project Type"
            DisplayName="Project Type"
            Group="Custom Columns"
    • Under the ‘ViewFields’ node add the fields that we want to see in the New and Edit forms.
      <FieldRef Name="LinkTitleNoMenu">
      <FieldRef Name="Project Type">
      <FieldRef Name="Project Status">
      <FieldRef Name="Team Member">
    • Set the debug URL to the site collection you want this list definition to be deployed and press F5 or choose ‘Deploy’ option when you right click the Project in the solution explorer.
    • Once deployed go to the Site Collection. Create a new List and choose your new ‘List Definition1’ instead of the Custom List option.


    • This will create a list with the desired site columns from the content type. If you enable management of Content Types in this list you can see lineage of the columns.


    This concludes the four part series on Content Types.

    Useful Links:

    Part – 1 , Part – 2 , Part – 3 , Part – 4


    3 Responses

    1. […] All about Microsoft Office SharePoint Server Content Type – Part 4 […]

    2. […] All about Microsoft Office SharePoint Server Content Type – Part 4 […]

    3. […] All about Microsoft Office SharePoint Server Content Type – Part 4 […]

    Leave a Reply

    Fill in your details below or click an icon to log in: Logo

    You are commenting using your account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s

    %d bloggers like this: