2

I searched everywhere, but could not find a solution that worked for me.

We've created a default document library, changed it a bit and saved it as a new document library template from the user interface. I can create document libraries based on this template successfully.

However, I have some CSOM code that creates a library automatically for me. It is now based on the template "101", which is the default document library. I want to create the library in code based on my custom document library.

I understood that I need a custom list template ID (which should be > 10000), but I cannot find out how I can find the custom list template id's. I found commands that list the default list template id's (i.e. 100, 101) but not the custom list template ID's. How can I find the custom list template ID's?

6

How to identify a SharePoint List Template ID (in Browser)

  1. The global variable g_wsaListTemplateId is available on the client side when the List is rendered

    Navigate to List - Press F12 to launch Dev Tools (details) and switch to Console window and run:

    console.log(g_wsaListTemplateId)

    enter image description here

  2. Export List Schema
    Construct the following query to export List Schema:

    https://fabifam.sharepoint.com/_vti_bin/owssvr.dll?Cmd=ExportList&List={ListGuid}
    

    where {ListGuid} corresponds to the List Guid

    To find out List Guid go to List - List Settings and copy List Guid from URL as demonstrated below

    enter image description here

    In the generated List Schema find the attribute named ServerTemplate that corresponds to List Template ID

  • Sorry, but I really don't understand your answer. What is console.log? Which List Guid are you talking about? – Martijn Burger Jan 29 '14 at 13:40
  • Martijn, the answer has been updated, hope it's more clear now – Vadim Gremyachev Jan 29 '14 at 14:41
  • Thanks. I tried both procedures. In both cases it returns 101, which is the id of the default document library and not the one with the content that I created. – Martijn Burger Jan 29 '14 at 16:05
1

Try this:

  1. Save the list template file (.stp) locally
  2. Change the extension to .zip and extract it
  3. Open manifest.xml and check TemplateID number
  4. Try by use this TemplateID in your code to create a list in a site that contains your custom list template
  • In my case that is "7", I thougt it should be greater that 10000: <TemplateID>7</TemplateID> <Configuration>0</Configuration> <FeatureId>{00BFEA71-E717-4E80-AA17-D0C71B360101}</FeatureId> <TemplateType>101</TemplateType> – Martijn Burger Jan 29 '14 at 10:28
  • I saved one in my VM and I got 111000 for TemplateID. Try it with 7 in your code anyway. – Naim Murati Jan 29 '14 at 10:46
  • I did. It still gives me "Invalid List Template ID". Code snippet: ListCreationInformation lci = new ListCreationInformation(); lci.Title = name; lci.TemplateType = libraryType; Where libraryType was 101 and is now 7 – Martijn Burger Jan 29 '14 at 11:00
0

Did you try to select all custom document templates programmatically? Look at the code example below

 var templates = SPContext.Current.Web.ListTemplates.OfType<SPListTemplate>().Where(t => t.IsCustomTemplate).Select(t => t.DocumentTemplate);

Here you can find how you can deal with it through client side object model

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.