Maxime Bombardier – SharePoint Architecture & Development : Deployment lifecycle when using Site Definitions and Features (including post production day)

15 12 2009




Todd Baginski’s SharePoint 2003 and MOSS 2007 Blog » Adding a Document Library Feature to a Site Definition in WSS V3 / MOSS 2007

11 12 2009




Team, Collaboration and Publishing Features

10 12 2009

Shown below is the list of Site and Web scoped features activated by Team, Collaboration and Publishing site definitions.

Site Collection Scope.

C85E5759-F323-4EFB-B548-443D2216EFB5 - Workflow Expiration
02464C6A-9D07-4F30-BA04-E9035CF54392 - Workflow Review
6C09612B-46AF-4B2F-8DFC-59185C962A29 - Workflow Signature
C6561405-EA03-40A9-A57F-F25472942A22 - Workflow Translation
F6924D36-2FA8-4f0b-B16D-06B7250180FA - Office SharePoint Server Publishing Infrastructure
  Activation Dependencies.
    A392DA98-270B-4e85-9769-04C0FDE267AA - Publishing Prerequisites
    AEBC918D-B20F-4a11-A1DB-9ED84D79C87E - Publishing Resources
    89E0306D-453B-4ec5-8D68-42067CDBF98E - Portal Navigation
    D3F51BE2-38A8-4e44-BA84-940D35BE1566 - Page Layouts and Master Pages Pack
B21B090C-C796-4b0f-AC0F-7EF1659C20AE - Office SharePoint Server Standard Site Collection Features
  Activation Dependencies.
    E978B1A6-8DE7-49d0-8600-09A250354E14 - Site Settings Link to Local Site Directory Settings page
    14AAFD3A-FCB9-4bb7-9AD7-D8E36B663BBD - SharePoint Portal Server Local Site Directory Capture Control
    5F3B0127-2F1D-4cfd-8DD2-85AD1FB00BFC - Portal Layouts Feature
    2ED1C45E-A73B-4779-AE81-1524E4DE467A - Web Part Adder default groups
00BFEA71-1C5E-4A24-B310-BA51C3EB7A57 - Basic Web Parts
7AC8CC56-D28E-41f5-AD04-D95109EB987A - Site Collection Level Search Center Url Feature
8156EE99-DDFB-47bb-8835-7AE42D40D9B9 - Report Center Creation

Web Scope.

99FE402E-89A0-45aa-9163-85342E865DC8 - Office SharePoint Server Standard Site features
  Activation Dependencies.
    E8734BB6-BE8E-48A1-B036-5A40FF0B8A81 - Related Links scope settings page
    56DD7FE7-A155-4283-B5E6-6147560601EE - Portal Analytics Links
    0BE49FE9-9BC9-409d-ABF9-702753BD878D - Slide Library
94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB - Office SharePoint Server Publishing
22A9EF51-737B-4ff2-9346-694633FE4416 - Publishing Web Feature
541F5F57-C847-4e16-B59A-B31E90E6F9EA - Portal Navigation Properties
00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5 - Team Collaboration Feature (Lists)
  Activation Dependencies.
    00BFEA71-D1CE-42de-9C63-A44004CE0104 - AnnouncementsList Feature
    00BFEA71-7E6D-4186-9BA8-C047AC750105 - ContactsList Feature
    00BFEA71-DE22-43B2-A848-C05709900100 - CustomList Feature
    00BFEA71-F381-423D-B9D1-DA7A54C50110 - DataSourceLibrary Feature
    00BFEA71-6A49-43FA-B535-D15C05500108 - DiscussionsList Feature
    00BFEA71-E717-4E80-AA17-D0C71B360101 - DocumentLibrary Feature
    00BFEA71-EC85-4903-972D-EBE475780106 - EventsList Feature
    00BFEA71-513D-4CA0-96C2-6A47775C0119 - GanttTasksList Feature
    00BFEA71-3A1D-41D3-A0EE-651D11570120 - GridList Feature
    00BFEA71-5932-4F9C-AD71-1557E5751100 - IssuesList Feature
    00BFEA71-2062-426C-90BF-714C59600103 - LinksList Feature
    00BFEA71-F600-43F6-A895-40C0DE7B0117 - NoCodeWorkflowLibrary Feature
    00BFEA71-52D4-45B3-B544-B1C71B620109 - PictureLibrary Feature
    00BFEA71-EB8A-40B1-80C7-506BE7590102 - SurveysList Feature
    00BFEA71-A83E-497E-9BA0-7A5C597D0107 - TasksList Feature
    00BFEA71-C796-4402-9F2F-0EB9A6E71B18 - WebPageLibrary Feature
    00BFEA71-2D77-4A75-9FCA-76516689E21A - WorkflowProcessLibrary Feature
    00BFEA71-4EA5-48D4-A4AD-305CF7030140 - WorkflowHistoryList Feature
    00BFEA71-1E1D-4562-B56A-F05371BB0115 - XmlFormLibrary Feature




Creating a SharePoint List Template using a Feature

23 09 2009

Building on the last post about creating a content type, in this post we’ll create a custom list template which uses that content type and deploy it using a feature.

If you’ve ever taken a look at the schema definition file for a list template, you may baulk at it’s size and complexity, in fact you can ignore most of this, creating a custom list template turns out to be relatively straightforward.

A list template comprises 2 files;

  1. The list template.xml file
  2. The list template schema.xml file

Create the list template.xml file and add it to your feature manifest file;

<?xml version="1.0" encoding="utf-8"?>
<Elements Id="8f1d5d09-6834-40b7-b245-c62c0811596e" xmlns="http://schemas.microsoft.com/sharepoint/">
	<ListTemplate Name="MyTestListTemplate"
		  DisplayName="TestList"
		  Description=""
		  BaseType="0"
		  Type="100"
		  OnQuickLaunch="TRUE"
		  SecurityBits="11"
		  Sequence="410"
		  Image="/_layouts/images/itgen.gif" />
</Elements>

Note the Name and BaseType attributes, we will create a subfolder with the same name as the Name attribute and place the schema.xml file there. The BaseType attribute indicates the list type from which this list templates inherits which in this case is the basic custom list.
Add the listtemplate.xml file to the feature manifest;

<?xml version="1.0" encoding="utf-8"?>
<Feature  Id="adc873b4-fe40-4169-8304-c9a1dd697c2b"
          Title="MySiteTypes"
          Description="Description for MySiteTypes"
          Version="12.0.0.0"
          Hidden="FALSE"
          Scope="Site"
          ActivateOnDefault="FALSE"
          ImageUrl="GenericFeature.gif"
          DefaultResourceFile="core"
          xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="sitecolumns.xml"/>
    <ElementManifest Location="mycontenttype.xml"/>
    <ElementManifest Location="listtemplate.xml"/>
  </ElementManifests>
</Feature>

Now for the schema.xml file, create a subfolder in your feature named “MyTestListTemplate” and in that folder create a new XML file called schema.xml.
lt01
To populate this file you have some options;

  1. Create it manually (take a look at the huge amount of CAML!!)
  2. Copy the base Custom List schema.xml file and modify it
  3. Craft the list/views etc in SharePoint using the UI and export the template using SharePoint Manager or the SharePoint Solution Generator

Using one of these methods you should then modify your schema.xml file as follows;

Change the Name, Title and URL attributes;

<List Name="TestList" Title="TestList" Description="" Direction="0" BaseType="0"
		Url="Lists/TestList"
		FolderCreation="FALSE"
		EnableContentTypes="TRUE"
		Type="100"
		Id="8f1d5d09-6834-40b7-b245-c62c0811596e"
		xmlns="http://schemas.microsoft.com/sharepoint/">

The contenttypes section should contain only the content type(s) you’ve defined for this list;

	<ContentTypes>
		<ContentTypeRef ID="0x0100928100FAB05A4148BD6F4C8E6A716B40" />
	</ContentTypes>

To the Fields section add only the field definitions defined in the content types list in the above contenttypes section;

<Fields>
	<Field Type="Number" DisplayName="MyReference" Required="FALSE" Decimals="0" Commas="FALSE" Group="My Group" ID="{918BA6B8-60BC-417e-AEE5-F9E1A0A59144}" StaticName="MyReference" Name="MyReference" Customization="" SourceID="{6a05fd42-eda7-4fb7-9bfd-2a35ded20c24}" ColName="float1" RowOrdinal="0">
		<Default>0</Default>
	</Field>
	<Field Type="Choice" DisplayName="MyType" Description="Description of MyType" Required="FALSE" Format="RadioButtons" FillInChoice="FALSE" Group="My Group" ID="{1FDC83BE-D596-45e2-9DD3-AD3338798784}" StaticName="MyType" Name="MyType" Customization="" SourceID="{6a05fd42-eda7-4fb7-9bfd-2a35ded20c24}" ColName="nvarchar3" RowOrdinal="0">
		<Default>Person</Default>
		<CHOICES>
			<CHOICE>Person</CHOICE>
			<CHOICE>Place</CHOICE>
			<CHOICE>Thing</CHOICE>
		</CHOICES>
	</Field>
	<Field Type="Note" DisplayName="MyDetails" Description="Description of MyDetails" Required="FALSE" NumLines="5" RichText="FALSE" Sortable="FALSE" Group="My Group" ID="{AB31BEFA-A178-4a1e-B324-B73E9C15D5A8}" StaticName="MyDetails" Name="MyDetails" AllowHyperlink="TRUE" RichTextMode="Compatible" IsolateStyles="FALSE" AppendOnly="FALSE" Customization="" SourceID="{6a05fd42-eda7-4fb7-9bfd-2a35ded20c24}" ColName="ntext2" RowOrdinal="0">
		<Default>Unknown</Default>
	</Field>
</Fields>

Modify the ViewFields section of each View (there are 2 views defined by default, a HTML view and the AllItems view) to include the columns required;

	<ViewFields>
		<FieldRef Name="Attachments" />
		<FieldRef Name="LinkTitle" />
		<FieldRef Name="MyReference" />
		<FieldRef Name="MyType" />
		<FieldRef Name="MyDetails" />
	</ViewFields>

You might also want to use the LinkTitleNoMenu column which is a straight link column to the proprty page of the list item, rather than the LinkTitle column which includes the dropdown ECB menu.

If you have exported the schema.xml file using one of the methods mentioned, you should check that your View element(s) (except the view with BaseViewID of 0 zero) have the SetupPath attribute set correctly.

<View DefaultView="TRUE"
      Type="HTML" DisplayName="All Items" Url="AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x"
      SetupPath="pages\viewpage.aspx"
      ImageUrl="/_layouts/images/DECISION.GIF" WebPartZoneID="Main">
   ...
   ...
</View>

Finally check that the Forms section is as follows;

    <Forms>
      <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
    </Forms>

Build and Deploy the feature to your SharePoint site and activate the MySiteTypes feature.
lt02
The new “Test List” list template will now appear in the Custom Lists section of a sites Create page as shown.
lt03
You can now create a sample list based on this template.
lt04





Creating SharePoint Site Columns using a Feature

1 09 2009

In this post we will be creating some Site Columns and provisioning them into SharePoint using a feature. The tools we will be using are Visual Studio 2008 and WSPBuilder.

First create a new Visual Studio project using the WSPBuilder Empty project template.

sc00

Your new solution should look something like this.

sc01

Add a new project item to the solution using the WSPBuilder Blank Feature template.

sc01a

Name your feature something sensible and open the feature.xml feature definition file.

<?xml version="1.0" encoding="utf-8"?>
<Feature  Id="adc873b4-fe40-4169-8304-c9a1dd697c2b"
          Title="MySiteTypes"
          Description="Description for MySiteTypes"
          Version="12.0.0.0"
          Hidden="FALSE"
          Scope="Site"
          ActivateOnDefault="FALSE"
          ImageUrl="GenericFeature.gif"
          DefaultResourceFile="core"
          xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="sitecolumns.xml"/>
  </ElementManifests>
</Feature>

Update the feature.xml as above. The feature.xml generated by WSPBuilder is generally all you need, the changes I’ve made are to the Description attribute and the Scope attribute. Site Columns must be scoped at the Site Collection level.

I’ve added 2 other attributes;

  1. ActivateOnDefault – Enable/Disable activating this feature when the feature is installed.
  2. ImageURL – an image URL (relative to …/_layouts/images) to display against the feature in the feature gallery.

Now rename the features single element manifest file from elements.xml to sitecolumns.xml, open sitecolumns.xml and add the following XML.

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
	<Field Type="Number" DisplayName="MyReference" Required="FALSE" Decimals="0" Commas="FALSE"
			 Group="My Group" ID="{918BA6B8-60BC-417e-AEE5-F9E1A0A59144}"
			 StaticName="MyReference" Name="MyReference">
		<Default>0</Default>
	</Field>
	<Field Type="Choice" DisplayName="MyType" Description="Description of MyType"
			 Required="TRUE" Format="RadioButtons" FillInChoice="FALSE" Group="My Group"
			 ID="{1FDC83BE-D596-45e2-9DD3-AD3338798784}" StaticName="MyType" Name="MyType">
		<Default>Person</Default>
		<CHOICES>
			<CHOICE>Person</CHOICE>
			<CHOICE>Place</CHOICE>
			<CHOICE>Thing</CHOICE>
		</CHOICES>
	</Field>
	<Field Type="Note" DisplayName="MyDetails" Description="Description of MyDetails"
			 Required="FALSE" NumLines="5" RichText="FALSE" Sortable="FALSE" Group="My Group"
			 ID="{AB31BEFA-A178-4a1e-B324-B73E9C15D5A8}" StaticName="MyDetails" Name="MyDetails"
			 AllowHyperlink="TRUE" RichTextMode="Compatible" IsolateStyles="FALSE" AppendOnly="FALSE">
		<Default>Unknown</Default>
	</Field>
</Elements>

I’ve added 3 site solumns of type Number, Choice and Note (multi-line text field). Each field definition must have a unique ID value which is a GUID, and for clarity in this example I’ve grouped these fields together using the Group attribute.

There is quite a lot of CAML there even just for 3 fields, you can craft this manually yourself, but there is an easier way. You create the site columns using the UI, when you’re happy with them you use a third party tool to export the site column definitions concerned then take the output XML and place it in your feature. There’s a couple of tools I use, one is a custom STSADM command by Andrew Connell, the other is the SharePoint Manager which is an explorer like tool which allows you to drill down to field definitions to view the XML, it’s then just a copy and paste into your feature.

When exporting site column definitions this way, you must create new GUID ID values for each field.

More information about the Field definition schema can be found here and here on MSDN.

When naming fields I would usually set the Name and StaticName attributes to values without any whitespace and use the DisplayName attribute to give the field a more informative display name.

Now use the WSPBuilder Build and Deploy commands to build and deploy the Solution to SharePoint.

sc02a

After the solution has been deployed, browse to your SharePoint Site Collection and go to Site Settings – Site Collection Features and activate the MySiteTypes feature.

sc05

Then navigate to Site Settings – Site Columns under the Galleries section, and you should see your new site columns listed under the custom group “My Group”.

sc06

You can now use these site columns when you create Lists or Document Libraries, from the List or Document Library settings page choose Add from existing Site Column.

sc02b

Choose the columns to add to the list (check “Add to default View”), click OK and your custom site columns will be added to the List or Document Library.

sc07

Site Columns on their own however, aren’t entirely useful, it’s more usual to define sets of Site Columns, and using them to form Content Types, which in SharePoint are a whole lot more useful and represent a functional leverage point.

Creating a Content-Type using a feature is relatively straight forward, and we’ll do that in another post by building on the site columns built during this article.