Parlae Solutions Blog

Customized Instances of Non-Custom SharePoint List Templates


Table of Contents

  • Overview
  • List Template ID
  • Technique A: Content Type Binding
  • Technique B: Feature Event Receiver
  • Technique C: Custom Schema XML



Custom list definitions provide great flexibility, but there is a limitation. SharePoint has a great deal of functionality, such as special views, for its built-in list templates. Unfortunately, these features are lost when creating a custom list definition since they are tied to a specific template.

You may be asking, “But I created a library with a document library, why doesn’t that work?” A custom list definition with a document content type is not a document library. A custom list definition with a task content type is not a task list. A custom list definition is a custom template regardless of the content type(s) on the list. The content type(s) do not override that or in any way determine what the list’s template is.


List Template ID

Each list template or definition has a unique identifier. This ID is an integer called “Type” on the <ListTemplate/> element and called “TemplateType” on the <ListInstance/> element. This ID is what identifies the template of list. For example, a document library has a template ID of 101 and only list instances with a template ID of 101 are document libraries. Since custom lists have a different template ID, they cannot be document libraries.

Blog Image

To illustrate with a real example, SharePoint workflows require a task list to be associated with them so they have a place to create their tasks. A custom list with a workflow task content type will not work. They have to be associated specifically to a task list which has a template ID of 107. Creating an out-of-the-box instance of a task list is simple enough, but there are often custom workflow task content types for the workflow to be used.

This is where we run into the aforementioned limitations of the custom lists. SharePoint has functionality like this that is tied to a specific template ID. In cases like these, we need to customize the out-of-the-box list templates so that the template ID remains the same instead of creating a custom list. Fortunately, there are three solutions to this problem. Which solution to use, depends on how much we need to modify the list. Solutions A and B allow for little modification of the list. Solution C allows almost complete modification of the list.


Technique A: Content Type Binding

If the customization is just adding a custom content type to a list, the simplest way of doing this is with using a <ContentTypeBinding/> element. For example, for a document library (most attributes have been omitted for clarity):

Blog Image

This adds the content type specified by “ContentTypeId” to the list with the URL “Lists/MyDocumentLibrary.” A list instance may not even be needed as the binding can work on default list instances, such as the default document library.

A downside to this is that the default content type(s), in this case, “Document”, will remain on the list. If the user is uploading documents to this library, the user can still choose to use the default content type. This is acceptable for a workflow task list since the user will not be creating items in the list.


Technique B: Feature Event Receiver

If we want to both add a custom content type and remove the default content type from the out-of-the-box list instance, only using a <ContentTypeBinding/> element, as described in the previous section, will not be enough. In this case, there is no XML way of removing a content type from a list. We must resort to using code in a feature event receiver to do so.

After the list instance, content type, and site columns have been created, add a feature receiver to the feature containing the list instance. Uncomment the feature activated event handler if it is still commented out. Then add the code to add the custom content type to the list and remove the default content type. For a document library, for example:

Blog Image

As with the previous option, a list instance may not be necessary. This option can also work the default list instances, such as the default document library.


Technique C: Custom Schema XML

If altering the content types is not enough, there is one more option that enables a great amount of customization to the list. A list instance can be specified to have a custom schema. This custom schema is actually a file that contains a list definition which overrides the default definition. In this way, we can keep the same list type ID, but have a custom definition for the list.

The first part is the list instance. In the element manifest (elements.xml by default), you will have the <ListInstance/> element as shown:

Blog Image

The “Title”, “Url”, and other not-shown attributes are all set normally. “TemplateType” is set to the ID number of the desired type, in this case 101 (document library). “FeatureId” must be set to the GUID of the feature which contains the default list definition. For this example, it is set to the feature containing the document library definition. Finally, there is the “CustomSchema” attribute. This attribute is the relative path (relative to the feature folder) of the file that contains the custom list definition that we want to override the default definition with.

The second part is the custom schema file. The custom schema XML file contains a <List/> element exactly like a custom definition would. Since we are starting with a default definition, it is best to copy the default definition, such as for the document library, out of the hive and into this file. For example, in SP2013, the document library list definition is located at “C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\FEATURES\DocumentLibrary\DocLib\schema.xml”.

Blog Image

When all is setup, the file structure should be an instance folder with an element manifest and an element file similar as shown:

Blog Image

Note that when using a custom schema, a <ListTemplate/> element is not used.


Please share if you thought this post was worth reading!


Schedule a Free Consultation

Thank you for your interest in Parlae Solutions. One of our team members will be happy to assist you. If you prefer to be contacted by phone, please provide a phone number and the best time to reach you in your message. If you need immediate assistance, please call (216) 526-2737.