Stumbling Through

Join me as I stumble, bumble and fumble my way through some new developer technologies. We'll laugh, we'll cry, there may be a mouse tossed through a monitor, but in the end we will all hopefully learn something.
in

Stumbling Through: SharePoint 2007 (Content Types - Part III)

While in the previous 'Content Type' stumbling through posts we ended up with something very useable, I thought I'd try one last thing to hammer home the power of content types and their object-oriented nature.  In our current example, we allow the user to track three types of assets:  Laptops, Monitors and Hard Drives, each of which have their own custom attributes in addition to common attributes inherited from a base 'Assets' content type.  What we neglected to do in the first pass, however, is create a property that tracks the asset's current status, that is, whether it is owned, in transit, lost, destroyed, etc.  This is an attribute that all content types will need to have, and the value should come from a list of pre-defined asset statuses.

The first order of business here is to create our simple 'Asset Statuses' list.  We'll do so by clicking 'Site Actions' and then 'Create':

image

Then select 'Custom List' to create:

image

Name the new list 'Asset Statuses' and ensure it gets placed on the Quick Launch menu:

image

After clicking 'Create', we are taken to the list edit screen.  Simply add a few Asset Statuses to the list, like 'Owned', 'Ordered', 'Lost', etc.:

image

So now that our list is set up, we need to revisit our Assets content type to add the 'Request Status' column.  To get back to our Assets content type, click the 'Site Actions' and then 'Site Settings' option:

image

Click 'Site content types' to get back to our list of content types:

image

From the list of content types, click our 'Assets' content type which was created in the previous posts:

image

Here, we can add our new 'Asset Status' column via the 'Add from new site column' link:

image

Name the new column 'Asset Status', and put it into the 'Clarity Asset Columns' group.  For the type, though, select the 'Lookup' action.  When this option is selected, new information appears in the 'Additional Column Settings' section that asks where the lookup values should come from.  We want to specify 'Asset Statuses' for the 'Get Information From' section, and 'Title' is the column to display:

image

Clicking 'Ok' adds the 'Asset Status' column to the 'Assets' content type, which effectively adds this column to the Laptop, Monitor, and Hard Drive content types which inherit from Assets.  We can prove this out by visiting our 'Clarity Assets' list off of the home page and adding a new item.  In this case, I chose to add a new 'Hard Drive' content type and we can see that it now accepts a value for 'Asset Status' from a dropdown populated with all of the statues we defined in our 'Asset Status' list:

image

I love this approach to data management in SharePoint 2007.  Object oriented behavior has always held a place near and dear to my heart, mostly because it allows me to do things like we did in this post - make additions to the behavior of all my objects with very little coding.  As the business rules for this asset tracking project get fleshed out, I can just add to what I have already defined, without having to redefine anything or start from scratch.

I hope I've helped clarify content types, as well as providing a real-world example on how they can be used.  As usual, my stumbling through feels as if I've only scratched the surface of this technology, but as the project evolves I will be sure to blog any additional gotchas or features that I stumble across.

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)