Saturday, May 27, 2017

Document Content Types

In this post we will see the implementation of document content types.

Document Content Type
In the previous post we discussed about the default list content types which is "Item". A document library is just an another form of list and has the default content type as "Document" which is inherited from the parent content type "Item".
However, the "Document" content type is simple and does not contain any metadata for documents in the document library except for the name, created by , created date, modified by and modified date information.

Let's consider an example of a document library named Employee reviews which is used to store the reviews for each employee as shown below. The default "Document" content type allows only name, so the only information that the document holds is the Employee name or ID, regardless of the information provided inside the document.
The ideal solution will be to add the metadata details like Employee ID, Name etc along with the document to make it robust and also searchable using a custom document content type, something like as shown below:

Implementing Document Content Types
1) Create the required Site Columns
2) Create new Content type
3) Add Content type to library

1) Create the required Site Columns
Go to Site Settings->Site columns.

Create the site columns required for the new content type as follows. You will notice that we have created the columns are created under a new group "SPTECHBYTES" so that it can be managed easily.


2) Create new Content type
Go to Site Settings->Site content types for creating new content type.

Create new list content type named "Employee Review" as follows. Please note that the parent content type will be "Document", since we are going to use it in a library. Also, we will create it under a new group named "SPTECHBYTES".
Since we created all the columns under the group "SPTECHBYTES", we can easily list down the columns and add to the content type.

All the columns will be added and now the content type is ready for use. You may explore the additional properties like Name, Group, Advanced settings etc for further customizing the content type.

3) Add Content type to library
Create a new custom document library named "Employee Reviews"and go to Library Settings->Advanced Settings.

To view\manage the content types, click "Yes" for the the "Allow management of content types" option.

You will notice that now there is new section named "Content Types" in the Library Settings page which will allow you to add/remove content types from the list. Click on "Add from existing site content types" link to add the "Employee Review" Site content type that we created in the above steps.

Add the "Employee Review" content type to library as follows. It would be easy to locate the content type if you select the group under which you created the content type (eg: "SPTECHBYTES" in our example).

Once the content type is added, go back to to the "Employee Reviews" list and click on "New Item" button. You will notice that now there is an additional link called "Employee Review".

Create\Upload a new file to the document library.

Once the document is uploaded you will be automatically redirected to the edit item form with all the columns that we included in the content type. In this way you can add additional information to the particular document uploaded.

Once saved, the item will be displayed as follows. (You may have to change the view to display all the fields).

Hope this post was informative! Please do leave your comments.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.