Cliff Green's Blog

Finding a SharePoint List Template Id

There are several ways to find out the ID for a List.  A typical scenario where a list template id is required is querying a list or set of lists using SPSiteDataQuery.  You can find the list template id by looking at the 12\TEMPLATE\FEATURES directory and finding the list in question.  Opening the element manifest for the feature you will notice an attribute named DocumentTemplate, which is the List Template ID or Type which will provide the list template type, also ID for the out of box templates.

<?xml version="1.0" encoding="utf-8" ?> 
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListTemplate Name="doclib" Type="101" 
    BaseType="1" OnQuickLaunch="TRUE" SecurityBits="11" 
    Sequence="110" DisplayName="$Resources:core,doclibList;" 
    Description="$Resources:core,doclibList_Desc;" Image="/_layouts/images/itdl.gif" 
    DocumentTemplate="101" /> 
</Elements>

Another method to do this leveraging the UI is to click Site Actions > Create.  The next screen provides a view of all the lists and document libraries that can be created on the site.  If you right click the list and select properties you will be presented the Url Address for the list.  Highlighting and scrolling to the end of the Url you will see a query string variable called ListTemplate.  The value presented is the list template ID.

image

A more dynamic method of finding this information in code is to leverage the object model.  SPWeb has a property called ListTemplates that returns a collection of the lists that can be created on the site.  The SPListTemplate class held in the collection has a property called DocumentTemplate property providing the List Template ID.

using( SPSite siteCollection = new SPSite("http://moss.litwareinc.com") ) {
  using( SPWeb web = siteCollection.OpenWeb() ) {
    foreach( SPListTemplate template in web.ListTemplates ) {
      Console.WriteLine(template.DocumentTemplate.ToString());
    }
  }
}

Another little known method for getting the ID, at least for those features that are out of the box, is to use the feature GUID, which has a format of OOBFxxx-xxxx-xxxx-xxxx-xxxxxxxxx101.  For example, the listing for a document library is 00BFEA71-E717-4E80-AA17-D0C71B360101.

Published Monday, August 04, 2008 2:11 PM by green.cliff
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

a-foton &raquo; Finding a SharePoint List Template Id said:

August 4, 2008 9:49 AM
 

Michael Greth MVP SharePoint Blog said:

Entwicklung SharePoint developer bookmarklets Consistent development of Master Pages, Page Layouts and

August 12, 2008 5:23 AM
 

Mirrored Blogs said:

Entwicklung SharePoint developer bookmarklets Consistent development of Master Pages, Page Layouts and

August 12, 2008 6:24 AM

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required
Submit

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker