this blog post, we will see how to create a custom content type then use it in a Document Library.
Here's' the problem: We need a custom content type 'ConfigurationFiles' which requires a site column of service tag. The service tag will be a text file because we will eventually need to enforce a specific format or pattern of 3 digits followed by a dash and 3 more digits. For example: 232-343 or 908-458.
Here's the solution: We will create a custom content type of 'ConfigurationFile' It will be based on the document content type and use a custom excel worksheet template. We will add a site column called ServiceTagNumber which will be of type text.
Create our custom content type 'ConfigurationFile'.
We are at the top level site of a new site collection based on the Team Site template for this demonstration. We are the site collection administrator. The url is http://intranet.contoso.com/sites/ctd
We are at the top level site of a new site collection based on the Team Site template for this demonstration. We are the site collection administrator. The url is http://intranet.contoso.com/sites/ctd
To create the custom content type: Site Actions > Site Settings
In the Galleries Section of the Site Administration Page click on Site content types.
Click Create to create a new custom content type.
Now we'll fill out the Name and Description as shown. We are careful to select Document Content Types as the Parent Content Type: Select parent content type from: and Document from the Parent Content Type drop down menus. We will leave this in the Custom Content Type Existing group. Then click the OK button.
We will now add the new site column ServiceTagNumber by clicking on the Add from new site column link.
We fill out the Column name: as ServiceTagNumber and use the default single line of text. We are not using spaces in our name in case we need to get to this property with code at some point in the future. When we are done we click the OK button at the bottom of the screen (not pictured)
Let's go ahead and customize the default template to use an Excel 2010 Spreadsheet as opposed to a Word 2010 document. Click on the Advanced Settings link in the Settings section of the Site Content Type Information Page.
Check the Upload a new document template and click Browse and upload your spreadsheet template. (I made one earlier and saved it to my desktop this was not shown in the instructions) then click the OK button.
Let's check the Document Information Panel settings by clicking on the Document Information Panel Settings link.
Make sure the Always show Document Information Panel check box is checked then click OK.
Time to create our Configuration Files Document Library. To do this we'll click Site Actions>New Document Library
We fill in the Create wizard as shown then click the Create button.
We'll click the Library settings to configure the Library to manage it's own content types.
We'll click on Advanced Settings
In the first section we check Allow management of content types then we click the OK button at the bottom of the page. (not shown)
We click the Add from existing site content types in the Content Types section of the Document Library Settings page.
Select Custom Content Types from the Select site content types from: drop down list. Then highlight ConfigurationFile and click on the Add> button then click OK.
Click on the Change new button order and default content type link so we can remove Document from the choice and thus change ConfigurationFile to the default content type.
We'll clear the Visible check box for Document and click OK.
Because there are only 2 content types currently listed and we've aced one of them ConfigurationFile becomes the default content type automatically.
Now we'll use the content type. Click on the ConfigurationFiles link in the breadcrumb.
Click the Documents tab to change the ribbons context and click New Document to create a new Configuration File.
You can click o.k. if you get the Open Document security warning.
Excel should open up and you should see the Document Information Panel at the top asking for a Title and ServiceTagNumber.
Notice the use of the template I created (not in these instructions) and uploaded as the default template for the new content type (in these instructions)
No comments:
Post a Comment