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="https://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("https://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.