Sunday, April 30, 2017

List Content Types

In this post we will discuss about the implementation of List Content Types in SharePoint.

Site Content Types
The Site Content types are created and managed at the site collection level. For creating and managing site content types, go to Site Settings->Site content types.
Once the site content types are created, we can easily add to any of the lists in the site collection or sub-sites under it.

List Content Types
Once the existing Site Content Types are added to a list, a local copy of the content type will be created by SharePoint and added to the list know as List Content Types. Further changes or additional columns will affect only this local instance and not the original Site Content Type.

Implementing List Content Types
1) Create the required Site Columns
2) Create new Content type
3) Add Content type to a list
4) Reuse Content Type in another list
5) Delete Content type from a list

Now lets see each of the above mentioned steps in details:

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" as follows. Please note that the parent content type will be "Item", since we are going to use it in a list. Also, we will create it under a new group named "SPTECHBYTES".
Once the content type is created, we need to add the site columns that we created in the above steps.
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 a list
Lets create a new custom list named "Employee Details". If you click on New Item, you will see that there is only default "Item" Content type which has only one column named "Title".
To view\manage the content types for this list go to List Settings->Advanced Settings and 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 List 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" Site content type that we created in the above steps.

Add the "Employee" content type to list 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 Details" list and click on "New Item" button. You will notice that now there is an additional link called "Employee".

Once you click on the "Employee" link, the new item form will be open with the columns that we included in the content type. 

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

4) Reuse Content types in another list
Repeat the above steps to add the "Employee" site content type to a new list named "Emergency Contacts". Here again a copy of the content type will be created for this list. Adding columns or deleting it will not affect the original "Employee" site content type at the site collection level.


5) Delete Content types from a list
Go to List Setting and click on the "Employee" content types. Click on the "Delete this content type link" to delete it from the list.

Please not that if there is any data related to the content type, you will not be able to delete the content type and face the following error. 

You can solve this issue in either of the following ways:
(i)  Delete all the list items from the list which are associated with this content type
(ii) Edit all the list items and change the content type from "Employee" to something else.
Try again to delete the content type and this time you will succeed.

Thank you for reading this post and please do let me know your comments!

No comments:

Post a Comment

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