HOW TO: Programmatically create a SharePoint 2010 External Content Type


 

I demonstrated how to make an external content type programmatically during the SPC 405 - Business Connectivity Services Runtime and Object Model Deep Dive session at the 2009 Microsoft SharePoint Conference.  Since the conference I have received a couple of dozen emails about the this topic.  Most of the emails ask for the code samples and an explanation of the code, and at least half of the emails inquire about when and why you may need to create an external content type programmatically.  Because this is obviously a hot topic I decided to write it up in a blog post.

Sample Business Context

To begin, let’s take a moment to understand what types of business situations lend well to programmatically creating external content types.  The diagram below illustrates a common business scenario where creating external content types programmatically makes a lot of sense. 

For example, an engineer in the engineering department creates a specification for a new product.  The purchasing department then contacts multiple suppliers to determine which suppliers the company will work with to secure the parts and components used to create the new product.  The new product and the suppliers are entered into the company’s ERP system.  Customer service representatives who support the product need quick access to the supplier data in the ERP system.  The customer service representatives have not been trained to use the ERP system, however they are familiar with web based applications.  To provide the customer service representatives with real time access to the product and supplier information in the ERP system an external content type may be automatically created when a new product and its associated supplier information is entered into the ERP system.  The external content type will correspond to the new product and supplier information and provide the ability for the customer service representatives to access the data within a SharePoint web site.

 image

The Solution

To build on the example above the first thing that needs to be done is to hook the creation of a new product and associated suppliers in the ERP system to the creation of an external content type.  There are several ways to do this and the appropriate method will depend on the system where the data is stored.  Workflows, batch jobs, triggers, and event callouts may all be viable options.  No matter which option is the best solution, eventually you will use the the Business Data Connectivity  (BDC)administration API to automate the creation of an external content type in SharePoint 2010.

The BDC administration API allows you to make changes to the metadata in the BDC metadata store.  This API is primarily found in the Microsoft.SharePoint.BusinessData.Administrationand the Microsoft.SharePoint.BusinessData.Administration.Client namespaces.  The Microsoft.SharePoint.BusinessData.Administrationnamespace is used when running on the SharePoint server and the Microsoft.SharePoint.BusinessData.Administration.Clientnamespace is used when running on a client machine (machine other than a server in a SharePoint server farm).  The Microsoft.BusinessData.MetadataModel and Microsoft.BusinessData.Runtimenamespaces are also used to support creating external content types.

As I mentioned earlier, the exact implementation you choose will depend on your environment.  Instead of providing a click by click tutorial to create a console application, Web/WCF service, Web Part, or the other usual suspects, I’ll just focus on the code you need to get the job done and leave the implementation details up to you.  This example creates an external content type for the Customers table in the AdventureWorks sample database.  This is the same example I demoed at the 2009 Microsoft SharePoint Conference, however I updated it to run on Beta 2.  You can download the complete source code, updated for SharePoint 2010 Beta 2, here.

Assembly references

To begin, create the appropriate Visual Studio project for your implementation and add references to the following assemblies.

Assembly Location Usage
Microsoft.BusinessData.dll C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI Needed on both client and server
Microsoft.SharePoint.dll C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI Solution runs on a SharePoint server
Microsoft.SharePoint.BusinessData.Administration.Client.dll C:\Program Files\Microsoft Office\Office14 Solution runs on a machine other than a SharePoint server (client)

This example assumes you are not running on the SharePoint server and uses the Microsoft.SharePoint.BusinessData.Administration.Client.dll assembly.  Therefore, the Microsoft.SharePoint.BusinessData.Administration.dll assembly is not added as a reference.

References

The Code

The BDC administration API is easy to use.  The classes, properties, and methods you use to create an external content type map directly to the metadata structures which define a BDC Model.  If you are already familiar with BDC Models (Application Definitions in MOSS 2007 speak) this code will look familiar to you as well.

Using Statements

To begin, add the following using statements to your project.

using Microsoft.SharePoint.BusinessData.Administration.Client;
using Microsoft.BusinessData.MetadataModel;
using Microsoft.BusinessData.Runtime;

Connect to the BDC Metadata Store

Next, connect to the BDC Metadata Store where the definitions for external content types are stored.  In this case I am connecting to the BDC Metadata Store associated with the site located at the following URL: http://dev1/sites/Team Site

AdministrationMetadataCatalog catalog = AdministrationMetadataCatalog.GetCatalog("http://dev1/sites/Team Site");

Create the Model, LobSystem, and LOBSystemInstance

Next, create the Model, LobSystem, and LobSystemInstance.  Pay special attention to the names you provide for these items because they appear in the External Content Type picker and your users will see them.  See the screenshot near the end of this article for more details.

//Create a new customer model
Model customerModel = Model.Create("CustomerModel", true, catalog);

//Make a new Customer LobSystem
LobSystem awLobSystem = customerModel.OwnedReferencedLobSystems.Create("Customer", true, SystemType.Database);

//Make a new AdventureWorks LobSystemInstance
LobSystemInstance awLobSystemInstance = awLobSystem.LobSystemInstances.Create("AdventureWorks", true);

//Set the connection properties
awLobSystemInstance.Properties.Add("AuthenticationMode", "PassThrough");
awLobSystemInstance.Properties.Add("DatabaseAccessProvider", "SqlServer");
awLobSystemInstance.Properties.Add("RdbConnection Data Source", "DEV1");
awLobSystemInstance.Properties.Add("RdbConnection Initial Catalog", "Customers");
awLobSystemInstance.Properties.Add("RdbConnection Integrated Security", "SSPI");
awLobSystemInstance.Properties.Add("RdbConnection Pooling", "true");

Create the Entity

Next, create the Entityto represent the Customers table and define which column(s) make up the identifier for the Entity.

//Create a new Customer Entity 
Entity customerEntity = Entity.Create("Customer", "AdventureWorks", true, new Version("1.0.0.0"), 10000, CacheUsage.Default, awLobSystem, customerModel, catalog);
//Set the identifier - CustomerID column
customerEntity.Identifiers.Create("CustomerId", true, "System.Int32");

Define the Specific Finder Method, Parameters and Type Descriptors

Next, create the specific finder Method, specify the query it will use, and define the input and output parameters associated with it.  The specific finder Method returns exactly one row of data from the data source, given an identifier.

//Create the specific finder method
Method getCustomerMethod = customerEntity.Methods.Create("GetCustomer", true, false, "GetCustomer");
//Specify the query
getCustomerMethod.Properties.Add("RdbCommandText", "SELECT [CustomerId] ,
[FirstName] , [LastName] , [Phone] , [EmailAddress] , [CompanyName] FROM
[Customers].[SalesLT].[Customer]
WHERE [CustomerId] = @CustomerId"
);
//Set the command type
getCustomerMethod.Properties.Add("RdbCommandType", "Text");
//Create the CustomerID input parameter
Parameter customerIDParameter = getCustomerMethod.Parameters.Create("@CustomerId", true, DirectionType.In);
//Create the TypeDescriptor for the CustomerID parameter
customerIDParameter.CreateRootTypeDescriptor(
"CustomerId", true, "System.Int32",
"CustomerId", new IdentifierReference("CustomerId",
new EntityReference("AdventureWorks", "Customer", catalog), catalog),
null, TypeDescriptorFlags.None, null, catalog);
//Create the Customer return parameter
Parameter customerParameter = getCustomerMethod.Parameters.Create("Customer", true, DirectionType.Return);
//Create the TypeDescriptors for the Customer return parameter
TypeDescriptor returnRootCollectionTypeDescriptor = customerParameter.CreateRootTypeDescriptor(
"Customers", true,
"System.Data.IDataReader, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"Customers", null, null, TypeDescriptorFlags.IsCollection, null, catalog);
TypeDescriptor returnRootElementTypeDescriptor = returnRootCollectionTypeDescriptor.ChildTypeDescriptors.Create(
"Customer", true,
"System.Data.IDataRecord, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"Customer", null, null, TypeDescriptorFlags.None, null);
returnRootElementTypeDescriptor.ChildTypeDescriptors.Create(
"CustomerId", true, "System.Int32", "CustomerId",
new IdentifierReference("CustomerId",
new EntityReference("AdventureWorks", "Customer", catalog),
catalog), null, TypeDescriptorFlags.None, null);
returnRootElementTypeDescriptor.ChildTypeDescriptors.Create(
"FirstName", true, "System.String", "FirstName",
null, null, TypeDescriptorFlags.None, null);
returnRootElementTypeDescriptor.ChildTypeDescriptors.Create(
"LastName", true, "System.String", "LastName",
null, null, TypeDescriptorFlags.None, null);
returnRootElementTypeDescriptor.ChildTypeDescriptors.Create(
"Phone", true, "System.String", "Phone",
null, null, TypeDescriptorFlags.None, null);
returnRootElementTypeDescriptor.ChildTypeDescriptors.Create(
"EmailAddress", true, "System.String", "EmailAddress",
null, null, TypeDescriptorFlags.None, null);
returnRootElementTypeDescriptor.ChildTypeDescriptors.Create(
"CompanyName", true, "System.String", "CompanyName",
null, null, TypeDescriptorFlags.None, null);
//Create the specific finder method instance
getCustomerMethod.MethodInstances.Create("GetCustomer", true,
returnRootElementTypeDescriptor, MethodInstanceType.SpecificFinder, true);

Define the Finder Method, Parameters and Type Descriptors

Next, create the finder Method, specify the query it will use, and define the output parameters associated with it.  The finder Method returns all of the rows of data from the data source which its query defines.

//Create the Finder method
Method getCustomersMethod = customerEntity.Methods.Create("GetCustomers", true, false, "GetCustomers");
//Specify the query
getCustomersMethod.Properties.Add("RdbCommandText", "SELECT [CustomerId] , [FirstName] , [LastName] , [Phone] , [EmailAddress] , [CompanyName] FROM [Customers].[SalesLT].[Customer]");
//Set the command type
getCustomersMethod.Properties.Add("RdbCommandType", "Text");
//Create the Customer return parameter
Parameter customersParameter = getCustomersMethod.Parameters.Create("Customer", true, DirectionType.Return);
//Create the TypeDescriptors for the Customer return parameter
TypeDescriptor returnRootCollectionTypeDescriptor2 =
customersParameter.CreateRootTypeDescriptor(
"Customers", true,
"System.Data.IDataReader, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"Customers", null, null, TypeDescriptorFlags.IsCollection, null, catalog);

TypeDescriptor returnRootElementTypeDescriptor2 =
returnRootCollectionTypeDescriptor2.ChildTypeDescriptors.Create(
"Customer", true,
"System.Data.IDataRecord, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"Customer", null, null, TypeDescriptorFlags.None, null);

returnRootElementTypeDescriptor2.ChildTypeDescriptors.Create(
"CustomerId", true, "System.Int32", "CustomerId",
new IdentifierReference("CustomerId",
new EntityReference("AdventureWorks", "Customer", catalog), catalog),
null, TypeDescriptorFlags.None, null);

returnRootElementTypeDescriptor2.ChildTypeDescriptors.Create(
"FirstName", true, "System.String", "FirstName",
null, null, TypeDescriptorFlags.None, null);

returnRootElementTypeDescriptor2.ChildTypeDescriptors.Create(
"LastName", true, "System.String", "LastName",
null, null, TypeDescriptorFlags.None, null);

returnRootElementTypeDescriptor2.ChildTypeDescriptors.Create(
"Phone", true, "System.String", "Phone",
null, null, TypeDescriptorFlags.None, null);

returnRootElementTypeDescriptor2.ChildTypeDescriptors.Create(
"EmailAddress", true, "System.String", "EmailAddress",
null, null, TypeDescriptorFlags.None, null);

returnRootElementTypeDescriptor2.ChildTypeDescriptors.Create(
"CompanyName", true, "System.String", "CompanyName",
null, null, TypeDescriptorFlags.None, null);

getCustomersMethod.MethodInstances.Create("GetCustomers", true, returnRootCollectionTypeDescriptor2,
MethodInstanceType.Finder, true);

Commit the changes

Finally, commit the changes to the BCS Metadata Store.

//Publish the Customer Entity
customerEntity.Activate();

 

Verification

After the code executes check Central Administration to verify the external content type is successfully created.  Then create an external list to verify the external content type works as expected.

Central Administration

To verify the external content type is successfully created follow these steps.

  1. Open SharePoint Central Administration
  2. Click Application Management
  3. Click Manage service applications
  4. Click the Business Data Connectivity service
  5. In the ribbon, click Manage
  6. In the ribbon, click Edit
  7. Select BDC Models in the View dropdown list
  8. Verify the BDC Model is in the list 

    BDC Model List
  9. In the ribbon, click Edit
  10. Select External Content Types in the View dropdown list
  11. Verify the BCS Model is in the list 

    External Content Types List  

Create An External List

To verify the external content type works as expected follow these steps.

  1. Open the SharePoint web site where you created the external content type
  2. Log in as a user who has the permission to create lists
  3. Click the Site Actions menu
  4. Select View All Site Content
  5. Click Create
  6. In the Filter By section, click List
  7. Select External List
    Create External List
  8. Click the Create button
  9. In the Name textbox enter Programmatically Generated External Content Type
  10. Click the button to browse the external content types
     External Content Type Picker
  11. Select the Customer External Content Type in the External Content Type Picker 
    External Content Type Picker
  12. Click OK
  13. Click Create
  14. View the data from the data source in the external list
    Data in external list

Wrap Up

As always, I hope this article saves you time and effort and helps you understand how to put this technology to use.  There are several good BCS articles appearing on the Internet lately.  You may check them out at the following blogs.

BCS Team Blog
Nick Swan’s blog
Fabian Williams’ blog

Yeah baby, only 12 days and I’m on vacation in Mexico!!!

author: Todd Baginski | posted @ Tuesday, December 01, 2009 12:00 AM | Feedback (2)

Which SharePoint 2010 Site Template Is Right For Me?


 

When MOSS 2007 came out I created a blog post very similar to this one.  It turned out to be one of my most popular posts and I received many comments and private emails thanking me for putting the post together.  Since the post helped out so many folks I decided to create an updated version for SharePoint 2010.

SharePoint 2010 ships with many predefined site templates you may use to create site collections and sub sites. Sometimes the out of the box site templates will meet the needs of your project. Other times, the out of the box site templates may need to be enhanced.

Knowing which site template has the functionality you need to deploy, or use as a baseline for a custom site definition, is one of the key decisions you make when you architect a SharePoint deployment. This being said, it is important to understand the templates SharePoint 2010 comes with out of the box and what sub sites, lists and pages they support.

This post outlines the site templates SharePoint 2010 comes with out of the box and what sub sites, lists and pages they support.  As usual, I’ve documented several useful pieces of information developers will find handy when working with the out of the box SharePoint site templates.

If you install Silverlight on your machine you’ll be presented with a fancy new interface to create sites (shown below).  As you can see, SharePoint 2010 offers some guidance when creating new sites by providing descriptions and preview images for each out of the box template. However, not all of the descriptions list which resources the site comes provisioned with and the preview images are no help at all. See the image below, I think you will agree.

site creation screen

To better understand the inventory of out of the box site templates, I created a site collection based on each out of the box site template. After creating 29 different site collections (that’s 6 more than MOSS 2007 if you are keeping track) I realized it would be hard to remember what each one looks like and what resources they offer. So, I decided to take some screenshots and document the site templates.

Preview Images

If you care to see what all of the preview images look like, you can find them in the following directory on your SharePoint server:

C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS\1033\IMAGES

The file names for the preview images corresponding to each site template are listed in the tables below.

A More Detailed Look

If you care to see what each of the home pages for the site templates look like you can download screenshots of each and every site template in this zip file. The screenshots should provide you with a good understanding of the different layouts that come with each out of the box template.  This should save you a lot of time creating each type of site template on your own machine!

Here’s an example, showing the new Business Intelligence Center; oh how fancy!

Business Intelligence Center

Important planning information related to the out of the box site Templates!

Available Sub Site Templates

The next table lists the WEBTEMP XML fragment files each site template and configuration are defined in, the concatenated template and configuration string you need when making sites with the site template programmatically, and the file name of the preview image. If you wish to change the out of the box preview images I recommend backup up the existing preview images, then replacing them with your new preview images that have the same file names. Feel free to use the images I created from screenshots of each site template’s out of the box home page to do so. You can download them here.

Note: You may have to perform this process again after a service pack is applied in the future. Editing the various WEBTEMP files that come out of the box is not a recommended approach; that’s why I recommend this approach.

As I mentioned before, knowing which sub sites, lists, and pages are available within a given site template are key peices of information you will want to know when you architect a SharePoint solution.  The table below displays which sub site templates are available for a given parent site template.

Select a site template to filter the table:

  Available Sub Site Templates Site Definition Config Concatenated String Preview Image Name Defined in this WEBTEMP File
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Team Site STS 0 STS#0 stts.png WEBTEMP.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Blank Site STS 1 STS#1 stbs.png WEBTEMP.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Document Workspace STS 2 STS#2 stdw.png WEBTEMP.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Blog BLOG 0 BLOG#0 stbg.png WEBTEMP.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Group Work Site SGS 0 SGS#0 stgb.png WEBTEMP.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Visio Process Repository VISPRUS 1 VISPRUS#0 custprev.png WEBTEMPVISPR.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Basic Meeting Workspace MPS 0 MPS#0 stmw.png WEBTEMP.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Blank Meeting Workspace MPS 1 MPS#1 stbm.png WEBTEMP.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Decision Meeting Workspace MPS 2 MPS#2 stdm.png WEBTEMP.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Social Meeting Workspace MPS 3 MPS#3 stsm.png WEBTEMP.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Multipage Meeting Workspace MPS 4 MPS#4 stmm.png WEBTEMP.XML
Central Administration;Team Site;Blank Site;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Assets Web Database ACCSRV 1 ACCSRV#1   WEBTEMPACCSRV.XML
Central Administration;Team Site;Blank Site;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Charitable Contributions Web Database ACCSRV 3 ACCSRV#3   WEBTEMPACCSRV.XML
Central Administration;Team Site;Blank Site;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Contacts Web Database ACCSRV 4 ACCSRV#41   WEBTEMPACCSRV.XML
Central Administration;Team Site;Blank Site;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Issues Web Database ACCSRV 6 ACCSRV#6   WEBTEMPACCSRV.XML
Central Administration;Team Site;Blank Site;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Projects Web Database ACCSRV 5 ACCSRV#5   WEBTEMPACCSRV.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Document Center BDR 7 BDR#7 preview.png WEBTEMPBDR.EN-US.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Records Center OFFILE 1 OFFILE#1 strc.png WEBTEMPOFFILE.XML
Business Intelligence Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Business Intelligence Center BICenterSite 0 BICenterSite#0 bicenterlogo.png WEBTEMPPPSMA.XML
  My Site Host SPSMSITEHOST 0 SPSMSITEHOST#0 perstemp.gif WEBTEMPSPS.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Personalization Site SPSMSITE 0 SPSMSITE#0 stps.png WEBTEMPSPS.XML
Team Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Enterprise Search Center;FAST Search Center; Enterprise Search Center SRCHCEN 0 SRCHCEN#0 template_srch_cntr.png WEBTEMPSPS.XML
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site;Publishing Site With Workflow Basic Search Center SRCHCENTERLITE 0 SRCHCENTERLITE#0 template_srch_cntr_lite.png WEBTEMPSRCH.XML
Team Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Enterprise Search Center;FAST Search Center; FAST Search Center SRCHCENTERFAST 0 SRCHCENTERFAST#0 template_srch_cntr_lite.png WEBTEMPSRCH.XML
Visio Process Repository;Business Intelligence Center;Personalization Site;Enterprise Search Center;FAST Search Center;Enterprise Wiki;Publishing Portal;Publishing Site;Publishing Site With Workflow Enterprise Wiki ENTERWIKI 0 ENTERWIKI#0 IPPT.gif WEBTEMPSPS.XML
  Publishing Portal BLANKINTERNETCONTAINER 0 BLANKINTERNETCONTAINER#0 IPPT.gif WEBTEMPSPS.XML
Visio Process Repository;Business Intelligence Center;Personalization Site;Enterprise Search Center;FAST Search Center;Enterprise Wiki;Publishing Portal;Publishing Site;Publishing Site With Workflow Publishing Site CMSPUBLISHING 0 CMSPUBLISHING#0 stpb.png WEBTEMPSPS.XML
Visio Process Repository;Business Intelligence Center;Personalization Site;Enterprise Search Center;FAST Search Center;Enterprise Wiki;Publishing Portal;Publishing Site;Publishing Site With Workflow Publishing Site With Workflow BLANKINTERNET 2 BLANKINTERNET#2 stpw.png WEBTEMPSPS.XML

New Site Templates

The following site templates are new to SharePoint 2010.

Group Work Site
Visio Process Repository
Assets Web Database
Charitable Contributions Web Database
Contacts Web Database
Issues Web Database
Projects Web Database
Business Intelligence Center
Enterprise Search Center
Basic Search Center
FAST Search Center
Enterprise Wiki

Deprecated / Removed Site Templates

The following site templates are deprecated or removed in SharePoint 2010.

Wiki Site
Site Directory
Report Center
Search Center with Tabs
Search Center
Collaboration Portal
News Site

Available Lists

Similarly, the table below displays which lists are available for a given site template.

Select a site template to filter the table:

  Available Lists
Team Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;Personalization Site;Enterprise Search Center;FAST Search Center;Enterprise Wiki;Publishing Portal;Publishing Site;Publishing Site With Workflow Asset Library
Business Intelligence Center Dashboards Library
Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;Personalization Site;Enterprise Search Center;Basic Search Center;Publishing Site Data Connection Library
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Portal;Publishing Site;Publishing Site With Workflow Document Library
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site Form Library
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;FAST Search Center;Enterprise Wiki;Publishing Portal;Publishing Site;Publishing Site With Workflow Picture Library
Visio Process Repository Process Diagram Library (US Units)
Team Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Publishing Site Report Library
Team Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Publishing Site Slide Library
Team Site;Blank Site; Translation Management
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site Wiki Page Library
Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace Agenda
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site Announcements
Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site Calendar
Group Work Site;Multipage Meeting Workspace;Basic Search Center Circulations
Central Administration;Team Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site Contacts
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Portal;Publishing Site;Publishing Site With Workflow Custom List
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site Custom List in Datasheet View
Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace Decisions
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site Discussion Board
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Portal;Publishing Site;Publishing Site With Workflow External List
Central Administration;Team Site;Document Workspace;Blog;Group Work Site;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Portal;Publishing Site;Publishing Site With Workflow Import Spreadsheet
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site Issue Tracking
Team Site Languages and Translators
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site Links
Group Work Site Microsoft IME Dictionary List
Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace Objectives
Business Intelligence Center PerformancePoint Content List
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site Project Tasks
Central Administration;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;Personalization Site;Enterprise Search Center Status List
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Site Survey
Basic Search Center;FAST Search Center Tabs List
Central Administration;Team Site;Blank Site;Blog;Group Work Site;Visio Process Repository;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace;Document Center;Records Center;Business Intelligence Center;My Site Host;Personalization Site;Enterprise Search Center;Basic Search Center;FAST Search Center;Enterprise Wiki;Publishing Portal;Publishing Site;Publishing Site With Workflow Tasks
Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace Text Box
Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace Things To Bring
Central Administration Administrator Tasks
Central Administration Distribution Groups

Available Pages

Finally, the table below displays which types of pages are available to create within a given site template.

Select a site template to filter the table:

  Content Page Publishing Page Web Part Page
Central Administration;Team Site;Blank Site;Document Workspace;Blog;Group Work Site;Visio Process Repository;Document Center;Records Center;My Site Host;Personalization Site;Basic Search Center Yes No Yes
Business Intelligence Center;Enterprise Search Center;FAST Search Center;Enterprise Wiki;Publishing Portal;Publishing Site;Publishing Site With Workflow Yes Yes Yes
Assets Web Database;Charitable Contributions Web Database;Contacts Web Database;Issues Web Database;Projects Web Database;Basic Meeting Workspace;Blank Meeting Workspace;Decision Meeting Workspace;Social Meeting Workspace;Multipage Meeting Workspace No No No

Buried Treasure: Hidden Templates!

Many of the site templates listed in the following table are left over from the previous versions of SharePoint and are marked obsolete. However some of them may be created programmatically. I included the list of all the hidden site templates here for reference.

Hidden site templates (not including Global template or Central Administration):

Site Template Name Site Definition Configuration Concatenated String Preview Image Name Defined in this WEBTEMP File
Wiki Site WIKI 0 WIKI#0 wikiprev.png WEBTEMP.XML
Tenant Admin Site TENANTADMIN 0 TENANTADMIN#0   WEBTEMP.XML
Access Services Site ACCSRV 0 ACCSRV#0 bsprev.png WEBTEMPACCSRV.XML
(obsolete) Records Center OFFILE 0 OFFILE#0 strc.png WEBTEMPOFFILE.XML
Shared Services Administration Site OSRV 0 OSRV#0   WEBTEMPOSRV.XML
PerformancePoint PPMASite 0 OSRV#0 rchome.png WEBTEMPOSRV.XML
SharePoint Portal Server Site SPS 0 SPS#0 spshome.gif WEBTEMPSPS.XML
SharePoint Portal Server Personal Space SPSPERS 0 SPSPERS#0 perstemp.gif WEBTEMPSPS.XML
Contents Area Template SPSTOC 0 SPSTOC#0 spshome.gif WEBTEMPSPS.XML
Topic Area Template SPSTOPIC 0 SPSTOPIC#0 spshome.gif WEBTEMPSPS.XML
News Site SPSNEWS 0 SPSNEWS#0 spshome.gif WEBTEMPSPS.XML
Publishing Site BLANKINTERNET 0 BLANKINTERNET#0 stpb.png WEBTEMPSPS.XML
Press Releases Site BLANKINTERNET 1 BLANKINTERNET#1 stpb.png WEBTEMPSPS.XML
News Site SPSNHOME 0 SPSNHOME#0 template_news.png WEBTEMPSPS.XML
Site Directory SPSSITES 0 SPSSITES#0 template_site_dir.png WEBTEMPSPS.XML
Community Area Template SPSCOMMU 0 SPSCOMMU#0 spshome.gif WEBTEMPSPS.XML
Report Center SPSREPORTCENTER 0 SPSREPORTCENTER#0 strp.png WEBTEMPSPS.XML
Collaboration Portal SPSPORTAL 0 SPSPORTAL#0   WEBTEMPSPS.XML
Profiles PROFILES 0 PROFILES#0   WEBTEMPSPS.XML
Basic Search Center SRCHCENTERLITE 1 SRCHCENTERLITE#1 template_srch_center_lite.png WEBTEMPOSRV.XML

Leverage this information to create SharePoint sites programmatically

The concatenated template and configuration string is used when creating sites programmatically. See the last line of code below for an example.

//Create a new SPSite object corresponding to your top level site
SPSite newSite = new SPSite("http://dev");
 
//Create a new SPWeb object from the newSite object
SPWeb newWeb = newSite.OpenWeb();
 
//Return the collection of sub sites
SPWebCollection subSites = newWeb.Webs;
 
//Create a new sub site by adding it to the sub site collection
//The new site will have the following metadata:
//Full URL once created: http://dev/newsite
//Name: New Site
//Description: This is the description for my new site.
//Local ID set to 1033 – English
//Site Template: Team Site
//Use Unique Permissions: True
SPWeb newSubWeb = subSites.Add("newsite", "New Site", "This is the description for my new site.", 1033, "STS#0", true, false);

 

Once again, I hope this post comes in handy for you and saves you the time I spent digging through the SharePoint file system and creating dozens of SharePoint sites to find the information. All the information in this post comes from the public beta 2 version of SharePoint Server 2010.  I’ll update this post once SharePoint 2010 goes RTM.

author: Todd Baginski | posted @ Friday, November 20, 2009 12:00 AM | Feedback (4)