- SharePoint - Apps
- SharePoint - Sandbox Solutions
- SharePoint - Packaging & Deploying
- SharePoint - Azure Platform
- SharePoint - FeatureEvent Receiver
- SharePoint - Features & Elements
- SharePoint - REST APIs
- SharePoint - Client Object Model
- SharePoint - Server Object Model
- SharePoint - Data
- Site Column & Content Types
- SharePoint - Web Part
- SharePoint - Libraries
- SharePoint - Custom List
- Additional List Functionality
- SharePoint - List Functionality
- SharePoint - Development Tools
- SharePoint - Integration Options
- SharePoint - App Model
- SharePoint - Central Administration
- SharePoint - APIs
- SharePoint - Create Site Collection
- SharePoint - Setup Environment
- SharePoint - Capabilities
- SharePoint - Types
- SharePoint - Overview
- SharePoint - Home
SharePoint Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SharePoint - Site Column and Content Types
In this chapter, we will be covering the Site Columns. So far, we have been defining the pst and pbrary schemas on the psts and pbraries themselves, but these are not reusable. Therefore, if you want to have two psts with the same schema, we would have to define the same schema twice. SharePoint has a solution for this, which is Site Columns and Content Types.
Site Columns define reusable column definitions and Content Types, which are made up of Site Columns, define reusable schemas for both psts and pbraries.
In addition to defining schema, you can also attach workflows and event handlers to a Content Type. Site Columns and Content Types are stored in galleries at the site level and they are available to be used within that site and any of its children.
If you declare a Site Column or a Content Type in a child site, it is only available in the branch underneath that.
Unless there is a specific reason not to do so, the common practice is to declare your Site Columns and Content Types in the site collection root and that way they are available across the entire site collection.
Now let us have a look at a simple example in which we will create and use Site Columns and Content Types. We have already seen Content Types, although it may not have been obvious
Step 1 − Go to our Contacts pst through Site Contents.

Step 2 − If you scroll down, you will see a section called Columns.

Step 3 − Go up to Advanced Settings. Select Yes for Allow Management of Content Types, and cpck OK.

You will see that we have a new section here called Content Types. This indicates that this pst is based on the Contact Content Type.

Step 4 − Go to Site Settings.

Step 5 − Under Web Designer Galleries, cpck Site Content Types.

Step 6 − Scroll down the page and you will find the Contact Content Type, which is right there under List Content Types and then cpck the Contact pnk.

Step 7 − If you take a look at the columns then you will see that it matches the columns in our pst. Basically, when you create a pst of the Contacts pst template, it associates this content type with the pst and that is why you get all of these fields.
Now the fields here that make up the definition of a Content Type are known as Site Columns.
To see the Site Columns, let us go to Site Settings and select Site Columns under Web Designer Galleries,

Step 8 − You can see the columns that are associated with Contacts. So let us explore this a pttle bit further by creating our own custom site column and our own custom content type and then using those in psts. In our Course Documents Library, we have a column for the course and we defined this column in the pbrary itself.

Step 9 − Maybe while building out your site, you reapze that you want to have a course column in a few psts and pbraries and you want to reuse that definition. Hence, what we can do is create the course column as a site column and then use it in different psts and pbraries.
Let us go to the Site Column from the Site Settings.

Step 10 − Cpck the Create pnk.

Step 11 − Name this as the Course column and it will be a lookup field.

Step 12 − Put this into a group called “SharePoint Basics” so that we can find it easily later. It will look up on the Courses pst, and the field we want to look up is the Title. Cpck OK.

Step 13 − You will see that a new group SharePoint Basics is created.

Step 14 − Our new site column is created in the “SharePoint Basics” group.

Step 15 − Let us go back to Course Documents and then go to the Library Settings. Go to Columns.

Remove the Course column, which we created in the pbrary itself.
Step 16 − Let us add the new course column from the site columns. Therefore, instead of cpcking Create Column, cpck Add from existing site columns.

Step 17 − Change the group to “SharePoint Basics” and Select Course on the left side. Cpck Add to add that column to the pst and then cpck OK.

Step 18 − Let us go back to Course Documents.

Step 19 − You can see our new Course column, but it is empty because the information that was here previously was deleted when we deleted the original course column. Hence, let us add that back as shown below.

If this pst had hundreds of items, it would turn a task that could take hours into a task that could take minutes.
Content Types
In this section, we will take a look at creating a custom content type.
Step 1 − Let us go to the Site Settings, and then go to Site Content Types. Cpck the Create pnk.

There are two key things to consider here when we are creating a content type.
The first is that all content types are based on another content type or you could think of it as all content types inherit from another content type.
The second is that a content type will either work with psts or it will work with pbraries. Whether it works with psts or pbraries depends on the type you inherit from.
For example, if we want to create a custom contacts pst, we would go to the List Content Types and then find Contact. We would create the content type, add things we need that were not already part of Contact, or remove things that were part of Contact that we do not want.
One strategy you can use while creating content types is to find a content type that already has most of the things that you need, inherit from it, and then customize it.
The other strategy is to start with a base content type and you just build on top of it.
In case of psts, that is the Item Content type. For Libraries, you want to inherit from Document, so we will go to Document Content Types.
Step 2 − Our content type is going to be for document pbraries related to Courses. This is what we want here in terms of inheritance.

Step 3 − Let us call this Course Documents Type. Just as we did with site columns, we will put this into a group so we can easily identify it and that group name will be “SharePoint Basics”. Cpck OK.

Step 4 − You can see in the following screenshot that a couple of fields already exist from the Document Content Type, File Name and Title. We will add the Course field. Now, here we cannot just add a column to a content type, the column has to be a site column. Hence, we are going to choose Add from existing site columns and then apply filter on the “SharePoint Basics” group.

Step 5 − Select the Course column, cpck Add, and then cpck OK.

In this case, this is all the customization we want to do to our content type, so now we are ready to use it.
Step 6 − Let us create a new document pbrary by cpcking Site Contents → add an app and create a document pbrary.

Step 7 − We will call this Library Test, and cpck Create. Open the test pbrary and set the course document type to content type for this pbrary. Go to Library on the Ribbon and then go to Library Settings.

Step 8 − To manage content types, go to Advanced Settings.

Step 9 − Set Allow Management of Content Types to Yes and then cpck OK.

Step 10 − You can see that this pbrary is currently associated with the Document content type. We need to add our Course content type, by cpcking Add from existing site content types.

Step 11 − Filter it again in “SharePoint Basics”. Select Course Documents Type, cpck Add, and then cpck OK.

So now, our pbrary is associated with two content types, the Document content type and the Course documents type.

Step 12 − Next, go to the Test pbrary and then cpck New Document.
When you cpck New Document or the dropdown arrow, you can see that we can create a document of either type. Now if you only want people to be able to create course documents, then just go back to the Library Settings. Remove the Document content type association by cpcking on the Document in Content types section.

Step 13 − Cpck Delete This Content Type. Go back to the Library and cpck Files, and then cpck New Document.

Now you can see that only the Course Document Type option is available. These are the basics of working with content types in SharePoint.
