Search This Blog

Wednesday, December 15, 2010

Create a Custom Content Type

1. When your organization begins to use SharePoint 2007 or 2010, sooner or later they will want to discuss the subject of Content Types – What are they? When should they be used? How do we make custom content types? In this article I will try to answer those questions as well as take you through the step-by-step process of making a custom content type.

2. Microsoft provides the following discussion of Content Types:

“A content type is a reusable collection of metadata (columns), workflow, behavior, and other settings for a category of items or documents in a Microsoft SharePoint list or document library. Content types enable you to manage the settings for a category of information in a centralized, reusable way.

For example, imagine a business situation in which you have three different types of documents: expense reports, purchase orders, and invoices. All three types of documents have some characteristics in common; for one thing, they are all financial documents and contain data with values in currency. Yet each type of document has its own data requirements, its own document template, and its own workflow. One solution to this business problem is to create four content types. The first content type, Financial Document, could encapsulate data requirements that are common to all financial documents in the organization. The remaining three, Expense Report, Purchase Order, and Invoice, could inherit common elements from Financial Document. In addition, they could define characteristics that are unique to each type, such as a particular set of metadata, a document template to be used in creating a new item, and a specific workflow for processing an item.

You can use each of the content types in this example on any document library in the site hierarchy, and you can use all of them together on the same document library. When business requirements change, you can modify the content types to meet the new requirements and push down the updates to any document library where the content type is used.”

http://msdn.microsoft.com/en-us/library/ms472236.aspx

3. From this discussion we can derive the basic characteristics of Content Types:

a. They are reusable

b. They are a collection of metadata (columns)

c. Workflow, behavior, and other settings can be assigned to them

d. They can be centrally managed

e. Their settings can be inherited by other Content Types

f. They can be used throughout the site collection

g. Changes to a Content Type can be pushed to any lists that are using it

4. So now we need to create a custom content type for our new SharePoint application. Here is our scenario:

• The customer receives help request e-mails from various users

• The customer wants to receive these requests in his SharePoint site so he can use workflow and collaboration to develop, track, and monitor responses

• The customer will need to use a custom e-mail enabled SharePoint library

• When the e-mails arrive the SharePoint site must capture certain information from the e-mail itself as well as other calculated information from an event handler

• The customer will not directly create e-mail documents in the list, SharePoint will create the documents automatically when an e-mail arrives

• Below are the metadata fields the custom Content Type for our library must have:

o EmailID – Number

o Title – Single Line of text

o Date Received – Date and Time

o Due Date – Date and Time

o Reply Status – Choice

o E-mail Sender – Single Line of Text

o E-mail From – Single Line of Text

o E-mail To – Single Line of Text

o E-mail CC – Single Line of Text

o E-mail Subject – Single Line of Text

o E-mail Body – Multiple Lines of Text

o Event Log – Multiple Lines of Text

o DueDateNoTime – Calculated

o ReceivedDateNoTime – Calculated

• The Content Type will also have a workflow associated with it – the “Inbox” workflow

5. So, to begin with, we need to create a blank Content Type which we can then customize with the columns we need. Below are the steps for creating a custom content type:

• From the site’s front page, choose Site Actions -> Site Settings

• From the Site Settings page, under the Galleries heading, choose Site Content Types

• From the Site Content Type Gallery click on the Create Button

• From the New Site Content Type page, in the Name and Description section, provide a name and Description for the content type – we will use “Custom Inbox” as the name

• From the New Site Content Type page, in the Name and Description section, choose Parent Content Type from - we will use Document Content Types

• From the New Site Content Type page, in the Name and Description section, choose Parent Content Type – we will use Document

• From the New Site Content Type page, in the Group section, choose which group you want your content type to reside in - we will choose Existing Group: Custom Content Type

• Click the OK button

6. Next, we create the custom content type columns. (All the columns will be new custom site columns except Due Date, because this column already exists and its format is fine for our needs.) Below are the steps for adding a custom column:
• From the Site Content Type: Custom Inbox configuration page , under the columns heading, choose “Add from new site column”

• From the New Site Columns: Solutions page provide the name, field type, and pertinent information for each metadata item

• For each metadata item choose to Put this site column into: Existing group: Custom Columns




• In the Update List and Site Content Types section, choose No for the Update all content types inheriting from this type? Configuration





• Click OK

7. There is one existing site column to add, Due Date. Below are the steps for adding an existing site column:

• From the Site Content Type: Custom Inbox configuration page , under the columns heading, choose “Add from existing site column”

• From the Select Columns section, choose select columns from “All Groups”, Available Column “Due Date”, and choose Add

• From the Update List and Site Content Types section, Update all content types inheriting from this type? selection choose No






8. Our next step is to associate a SharePoint workflow with our custom content type. To do this we need to accomplish two actions – Removing the workflows we don’t want associated with the Content Type, and adding the workflow we do want associated. To remove the workflows we don’t want associated follow these steps:

• From the Site Content Type: Custom Inbox configuration page , under the settings heading, click on workflow settings

• From the Change Workflow Settings page, under workflows, choose Remove a Workflow

• From the Remove Workflows page, choose to remove the Approval, Collect Feedback, and Collect Signatures workflows





• Now click OK

• The three default workflows will now be removed

9. To add an association for our custom workflow follow these steps:

• From the Site Content Type: Custom Inbox configuration page , under the settings heading, click on workflow settings

• From the Change Workflow Settings page, under workflows, choose Add a Workflow

• From the Add a Workflow page, in the workflow section, choose to add the ContactUsInbox workflow





• Name the workflow - Contact Us Inbox Workflow

• In the Start Options section choose Allow this workflow to be manually started by an authenticated user with Edit Items Permissions and Start this workflow when a new item is created





• Now click the Next button

• On the next page add a comment “This workflow runs automatically whenever a new e-mail arrives”

• Then click OK to exit this configuration area

10. At this point we have our content type configured, but we still have not put it into us in our site, that is our next step. Since we created a custom Document Content Type, we will need to create a document library to house it. Let’s start by creating a document library in the usual way – we will call the library “Contact Us Inbox”. Once our library is created we are ready to associate our content type with it, to accomplish this follow the steps below:

• From the Document Library click on Settings -> Document Library Settings

• From the Document Library settings page, Under the General Settings header choose Advanced Settings

• From the Advance Settings page, in the Content Types section, for the Allow management of content types configuration choose – Yes, and then click OK

• From the Document Library settings page, under the Content Types Header, choose Add from existing content types

• From the Add Content Types page, in the Select Content Types section, from Available Site Content Types, choose “Custom Inbox”, and then click the Add button

• Click the OK button to return to the From the Document Library settings page

11. Now we need to remove the default Document content type, while SharePoint list and libraries can support multiple Content Types, in our scenario we only want this document library to support our custom content type. To remove the default Document content type follow these steps:

• From the Document Library settings page, under the Content Types Header, click on the Document content type

• From the List Content Type page, under the settings header, click on Delete this content type

• When the pop-up message box appears with the warning message “Are you sure you want to delete this content type” choose OK

• The content type will be deleted (but only from this one Document library) and you will be returned to the Document Library settings page

• Now the only content type used by this document library will be our Custom Inbox content type

12. Now go back to the Document library, and from the library menu choose New, and then from the drop down choose “Custom Inbox”. Your custom Inbox document should open and you should see all the associated metadata from your custom content type. Since all our documents will be created automatically when our custom SharePoint library receives an e-mail, we will not need to create a document manually and so we can close the document.

I hope that helps!

Tom Molskow

No comments: