Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand

Posts Tagged ‘content type’

70-488 Content Type with Template

Posted by Jean Paul on February 7, 2015

In this article I will show how to use a document template along with a content type. As you know content type can be configured against a list & library. In fact library is also a list.

Document Template

We can associate a document template along with a Document Content Type. This allows users to use a common format of document while they chose the New Document for the library.

Create Content Type

Create a new content type like below.


Open MS Word application and create a new file.


Save it as a document template format. Note that the extension is .dotx.


Go back to the content type and choose Advanced Settings. Choose the above template in the Document template section as shown below.


Save changes.

Create a new document library & set the above content type to the library.


Choose the library & New Document from the ribbon. You will see the document is created as shown below.



You can use the above technique for setting templates for an Excel library too.



In this article we have explored how to set a document template to a content type.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »

Manage Policies for Content Type

Posted by Jean Paul on February 5, 2015

Content Type allows association of Policies as well. The policy will get applied to all the items or documents of the particular content type. Here we can explore how to configure them.

Types of Policies

Following are the types of policies:

1. Retention

2. Auditing

3. Barcodes

4. Labels


Following are the steps to create a content type with policy.

Create your content type.


Choose Content Type > Advanced Settings link.


In the appearing page you will see the following policies.

1. Retention

2. Auditing

3. Barcodes

4. Labels

Retention policies allow us to specify when the content should be moved or disposed. We can specify events like Created Date + 1 year for deleting the content after 1 year of creation.

Auditing enables logging the editing, opening events along with the user information.

Barcodes policies enable users to specify barcodes for the documents.

Label polices allow users to add a label containing information about the document

Retention policy section is shown below.


Auditing policy section is shown below.


Barcodes policy section is shown below.


Labels policy section is shown below.



In this article we have explored how to configure policies for content types.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »

70-488 Manage Workflow Associations for a Content Type

Posted by Jean Paul on December 31, 2014

In this article we can explore how to associate Workflows with Content Types.


Workflow allows set of pre-defined activities to be executed.  Workflows work using Windows Workflow Foundation 4.0 engine in SharePoint 2013.


We can associate workflows against a list, library or content type.  Here we are focusing on associating workflow with content types.


Follow the steps below to associate a workflow with a content type.

Create a new site content type named Expense.


Then click the Workflow Settings and in the appearing page choose Add a workflow.


In the appearing page you can choose the workflow & enter name, configuration settings.


Choose the start option to start on creation of new item.


You will get the workflow created as below.


This concludes our workflow association. You can test the code by creating a content type item.


Once the workflow is created, it will fire for all the items created based on the Expense content type.



In this article we have explored how to associate Workflows with Content Types.

Posted in SharePoint, SharePoint 2013 | Tagged: , , , | Leave a Comment »

70-488 Create Content Type Event Receiver

Posted by Jean Paul on December 16, 2014

In this article we can explore how to create a content type event receiver.


We are using an existing content type of template type Contact. We are adding an event receiver which operates on the Item Add event. For time being, we are just using the event receiver to block the item adding with an error message.


Open Visual Studio and create a SharePoint 2013 Farm Solution.


Add a new Event Receiver as shown below.


Open the XML file and choose the template id as 105.


In the event handler code, use the following statements.


Now you are ready with the event receiver. Build & Deploy the project.


Testing the Event Receiver

Create a new Contacts list in SharePoint.


Try adding a new item & Save it. You should get the following error.


This concludes our simple example of using event receiver against content types. The above event receiver will fire for all the Contact content type instances.

You may wish to use advanced property manipulation based on your business scenario.


You can use SharePoint Manager a free tool for examining events for a content type. The tool is downloadable from:



In this article we have explored how to create an event receiver for a content type.

Posted in SharePoint, SharePoint 2013 | Tagged: , , , | Leave a Comment »

Resource Request – Content Type Example

Posted by Jean Paul on November 30, 2014

In this article I would like to share a real-life scenario of using content types.

Resource Request

You are working as an IT Support Person.  The company employees need to raise various resource requests like:

  • Computer
  • Virtual Machine
  • Tablet

You need to also capture the configuration information from them, like:

  • Computer – CPU Cores, RAM, HDD Size, HDD Type, Users, Admin Users etc.
  • Virtual Machine – Domain, All Computer parameters
  • Tablet – Model, Storage etc.

Additionally, all these should be tracked along with following fields:

  • Status – Open, In Progress, Closed
  • Requester
  • Resolver
  • Created Date
  • Resolved Date

Content Type

The above scenario is good for content type.  We can also apply content type inheritance here.


Following is the list.


Now go to the list > List Settings > Advanced Settings > Allow management of content types > Enable


Now go to Site Settings > Site content types


Following is the Computer content type inheriting from base content type.


Following is the Virtual Machine content type inheriting from Computer.


Following is the Tablet content type inheriting from base content type.


Associate Content Types

Now go to the List > List Settings > Advanced Settings > Add Content Types


Do not forget to remove the default Item content type from the list.

(Click on Item content type and choose Delete option)

Add New Item

Now try adding a new item to our Resource Request list.


You are ready now to expose the list to employees.  They can generate new resource requests in a much easier way & the IT Support won’t miss any important parameters regarding the resource.


Please note that unlike document libraries, the content type drop-down won’t appear in the new form Or along with the Create link.  You need to do certain JS or CSS customization to enable this.



In this article we have explored how to use content types in a Resource Request scenario.  Adding workflows / alerts would notify the IT Support people immediately.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »

Create Content Type using Object Model

Posted by Jean Paul on October 30, 2014

In this article we can try creating a Content Type using Server Object Model code.


Please follow the steps below to create the content type.

Create a Console Application & Add Reference to Microsoft.SharePoint.dll. Also make sure the project properties > Build tab > Prefer 32-bit is unchecked.


Use the following code for the console application.

using (SPSite site = new SPSite(“http://hpvm”))


using (SPWeb web = site.OpenWeb())


// Delete content type if already existss

if (web.ContentTypes[“CodeCT”] != null)


// Create content type inheritin from ‘Item’

SPContentType contentType = new SPContentType(web.ContentTypes[“Item”], web.ContentTypes, “CodeCT”);


contentType.Group = “Custom Content Types”;

contentType.Description = “Content Type created through Code”;

// Create Site Columns

string fieldName = web.Fields.Add(“Column 1”, SPFieldType.Text, false);

SPField field = web.Fields.GetFieldByInternalName(fieldName);


fieldName = web.Fields.Add(“Column 2”, SPFieldType.Number, false);

field = web.Fields.GetFieldByInternalName(fieldName);


fieldName = web.Fields.Add(“Column 3”, SPFieldType.DateTime, false);

field = web.Fields.GetFieldByInternalName(fieldName);


// Add Field References to Our Site Columns

contentType.FieldLinks.Add(new SPFieldLink(web.Fields.GetField(“Column 1”)));

contentType.FieldLinks.Add(new SPFieldLink(web.Fields.GetField(“Column 2”)));

contentType.FieldLinks.Add(new SPFieldLink(web.Fields.GetField(“Column 3”)));

// Add few fields from OOB Site Columns

contentType.FieldLinks.Add(new SPFieldLink(web.Fields.GetField(“_Status”)));

// Update




Console.WriteLine(“Content Type created successfully.”);


The code is executed below.

1. Delete any content type with name CodeCT

2. Create new content type

3. Add custom field definitions to the web

4. Add custom field references to the content type

5. Add OOB column _Status to the content type

6. Updates content type


For custom columns, we are actually creating a Site Column through code (Fields.Add) & Referring it to the content type (FieldLinks.Add).

Execute the code.


You can verify the new content type being created or not from Site Settings > Site content types.


Click on it & ensure the all columns are visible.


You can use the SPFieldType enum for finding more types.



In this article we have explored how to create content type using server object model code. The source code is attached for reference.

Posted in SharePoint, SharePoint 2013 | Tagged: , , , | Leave a Comment »

Create Content Type using Schema

Posted by Jean Paul on October 29, 2014

In this article we can explore how to create a content type using XML Schema.

Activities Summary

Following are our activities:

1. Create Project in Visual Studio

2. Define Content Type Fields

3. Deploy Solution


Create a new project in Visual Studio. Choose Farm Solution. Add New Item > Content Type into it from the Office/SharePoint category of templates.


Inherit from Item as parent.


Close the designer view of content type & use Solution Explorer to open the XML view.


You will get the following view.


Replace the content with following.

<?xml version=”1.0″ encoding=”utf-8″?>

<Elements xmlns=””&gt;

<Field ID=”{00D74D75-B775-4222-967D-D26973B8C5DB}” Name=”CustomField” DisplayName=”Custom Field” Type=”Text”/>

<Field ID=”{C3CD561C-D714-42DE-8112-C830B4108CEF}” Name=”CustomChoiceField” DisplayName=”Custom Choice Field” Type=”Choice”>







<!– Parent ContentType: Item (0x01) –>

<ContentType ID=”0x0100CB3ADB9F2D014E3F920C47C0B14D25BD” Name=”SchemaCT” Group=”Custom Content Types” Description=”My Content Type” Inherits=”TRUE” Version=”0″>


<FieldRef ID=”{00D74D75-B775-4222-967D-D26973B8C5DB}” Name=”Custom Field” DisplayName=”Custom Field”/>

<FieldRef ID=”{C3CD561C-D714-42DE-8112-C830B4108CEF}” Name=”Custom Choice Field” DisplayName=”Custom Choice Field”/>

<FieldRef ID=”{1DAB9B48-2D1A-47b3-878C-8E84F0D211BA}” DisplayName=”$Resources:core,Status;” Name=”_Status”/>




Let us try to understand what each XML block do:

· The Elements section specifies the XML namespace url. We can include Field definitions here. Fields are first defined & later referenced.

· The first Field is of type Text. We need to specify GUID for each Field

· The second Field is of type Choice. The Choice values are specified in child tag

· The section Content Type specifies information on content type like Name, Description, Group, Version etc.

· The FieldRefs section is important as it actually specified the Fields used in the content type. Please note that we are referring the Fields here which we defined previously.

· Each Field Reference should include the ID, Name and Display Name of it. We can also refer existing Site Columns here by using the ID. We are using 2 custom fields & 1 existing site column here.

Now save changes & Deploy the project. Once the deployment succeeded, open SharePoint to view the new content type in Site Settings > Site content types page.


You can see the columns being showing up there.


This concludes our content type creation using XML Schema. If you wanted to create different field types, please see the field types in references section.



In this article we have explored how to create a content type using XML Schema.

Posted in SharePoint, SharePoint 2013 | Tagged: , , , | Leave a Comment »

Content Type – Advantages, Creation, Association

Posted by Jean Paul on July 14, 2013

In this article I would like to reveal the advantages of Content Type in real world scenarios.

What is Content Type?

A content type is a reusable collection of metadata (columns), workflow behavior and other settings for a category of items or documents.


We can manage Content Types through the Site Actions > Site Settings > Content Types page.

Advantages of Content Type

Reusability: We can create a content type & reuse across the site. For example, we can create a content type named Expense & reuse it in multiple departments like HR, Marketing, Research etc.


Additional to columns, we can reuse the workflows, custom forms associated with Expense content type. The reusability feature helps in reducing time effort in creating redundant items.

Standardization: Content Type allows quick standardization of items through definition in one place.

Centralized Control: We can apply changes to existing content type & the associated list or library will reflect changes automatically.

For example, if we add a Description column to the above Expense Content type, the change will be reflected in all associated libraries.

Another example, we can create custom new/edit forms for a content type & the changes should reflect everywhere. So, quick standardization is possible through content type.

Default Content Type: We can add a new content type to a library or list & make it default. Default Content Type will be invoked while using the Add Document or Add Item links.

Multiple Associations: We can associate multiple content types to a list or library. For example a Project Library can have different content type associated like: Plan, Expense, Meeting, Discussion etc.

Creating Content Type

In this step, we can quickly create a content type. Open Site Actions > Site Settings > Site content types link as shown below:


In the appearing page, click the Create button.


You should get the screen below to enter the Content Type detail. You can create a content type inheriting from existing content types like Item, Document, Folder etc.

For the time being, please select the Item content type from List Content Types group. Enter the name of new content type as Expense.


Click OK button to save changes. You can see the new content type created in the content types page, make sure you check under the Custom Content Types group.


You can edit the above Content Type & add remaining columns Amount, Date & Person.


Now we are ready to associate the above content type to a List. As we have created a List Content Type, we can associate it with List. (for library, we need to create Document content type)

Open an existing List & choose List Settings. From the Advanced Settings, check the option Allow Management of content types.


Coming back to the List Settings page, choose the Add from existing content type link.


In the appearing page, you can select our Expense content type & click the Add button.


After clicking Add button, click Ok button to continue.

Now you are ready to use the new content type. Go to the List, click the New drop down, You can see the Expense item listed there.


We can make a content type as Default which will set the New command to the specified item.

On clicking the Expense item, you can see the dialog box with Expense fields.



Please note that wise usage of Content Type, in the long run, should save Time, save Effort and increase Quality of Content Management.



In this article we have explored Content Type, Advantages, Creation and Association.

Posted in SharePoint, SharePoint 2010 | Tagged: , , , , | Leave a Comment »

Content Type as Metadata – Frequently Asked Questions

Posted by Jean Paul on May 30, 2013

In this article I would like to emphasize on Content Type as a Metadata, the Scenarios involved & frequently asked Questions.

What is Content Type?

Content type is a reusable collection of Metadata (columns), workflow, behavior, and other settings. Definition from MSDN:

“A content type is a reusable collection of settings that you want to apply to a certain category of content. Content types enable you to manage the metadata and behavior of a document, item, or folder in a centralized, reusable way. ”


What are the advantages of Content Type?

Content Type provides following advantages:

1. Centrally Managed We can define content type in a central location & this improves the Accuracy & Consistency.

2. Reusable We can reuse a content type across multiple libraries, sites, site collection & web application. This reduces the repetition work.

3. Metadata Content Type allows us to create columns for the underlying data involved.

4. Behavior We can associate workflows for content types. This enables workflow to be started across different libraries which uses same content type. Eg: A document of content type ‘Contract’ requires ‘Approval’ workflow to be started.

5. Retention Policies We can associate Information Management Policies for content types. This allows global policy application for entire document/item with specific content type. For example: We can set a document archiving policy for all ‘project’ content type document with age greater than 3 years.

6. Content Standardization As the content type is centralized & managed by authorized professionals, the Quality of Data will be much better.

7. Custom Forms We can associate custom forms with each content type. For example an Expense content type can have a custom form showing lookup values.

8. Hierarchical We can create new content type from existing content types. This allows reusing existing structure.

Can we assign Content Type to List?

Yes. We can have Document content type & List content type.

Can a document library have multiple Content Types?

Yes. For an example scenario, we can have a project document library which contains ‘Requirement’ content type, ‘Documentation’ content type which is different type of documents.

Can a parent site Content type reusable in child site?

Yes. Content type created in parent site is available for sites & sub sites.

What is Content Type Hub?

A content type created in Web Application can be made available in another Web application. Such a web application created for Content Type sharing is called Content Type Hub. We need to configure Managed Metadata Service (MMS) for this purpose.

What is the difference between Site Content Type & List Content Type?

When you create a content type in site level, it is a Site Content type. When you add the content type to a List level, it is copied & becomes List content type.

What is push-down operation?

As site content type are copied to list content types, the changes made to parent are not propagated to child.  To propagate changes we use push-down operations.

Is Content Type a Metadata?

Yes. Content Type can be called as Metadata. Additional to Metadata, Content Type can have behavior, forms & retention policies.

When I should use Taxonomy Terms instead of Content Types?

If you wanted to classify the entire document & items, you can assign Taxonomy Terms.

What are the different Metadata infrastructures available?

I would say Columns, Site Columns, Content Types, Terms are those available in SharePoint.



Columns are the List/Library Columns, but Site Columns represent reusable Columns in site level.

Can i live without Content Type?

No! In SharePoint everything is Content Type.  The base content type include Folder, Document & Item.

When should i use Site Column?

Site Column is just a reusable column & can be considered as Sub set of Content Type.  Site Column can be used within a Content Type.  You can use Site Column for custom column requirements.  For example SharePoint 2010 does not have an SSN column.  You can create a custom SSN site column with associated validations & behaviors.

Can we Index the Content Type Column?

No.  But you can index the list column where list is an instance of content type.

How to make a Content Type hidden?

Use the ‘Hidden’ property of content type (PowerShell / Server Object Model), Place in the _Hidden group.

How can we protect a Content Type from changes?

Set the Read Only property to true OR mark it as Sealed content type.  Sealed content type are not updated through push-down operations.



In this article we have explored Content Type advantages & associated frequently asked questions.

Posted in SharePoint | Tagged: , , , , , , | Leave a Comment »