MOSS as an Application Development Platform
October 9, 2007
I recently recorded a DNR show on MOSS. During the session, a question about the benefit of using MOSS platform elements such as "List" came up. How can developers leverage these to build applications more productively. Let me try to answer this question with an example. Imagine that we are required to build a web page that displays a list of webcast recordings. Users with administration permissions are allowed to upload new webcast recordings, and update (and delete) existing items in the list. Other users can only view existing items in the list. Further, we also have a UI requirement to customize the list rendering such that in addition to the name of the webcast and an icon (that allows users to initiate streaming), the list also allows users to download the associated presentation slide deck as well as view the description of the webcast.
One approach for implementing the above requirement would be to define a webcast content type that has fields that correspond to the columns described above. We can then associate the webcast content type with a SharePoint list. Using CAML (Collaborative Application Markup Language) we can customize the UI of the list to meet our requirements.
Note that we could have just created a list using site columns instead of defining a content type. The benefit of using a content type is that it is a reusable type that can be associated to other list instances. We can also create new content types that derive from webcast content type. SharePoint uses ASP.NET forms to allow users to insert and update list items. All data associated with the list is automatically stored in the content database. The Figure below depicts a custom webcast list.
While it may not seem difficult to add a list control on an ASP.NET page and hook-up some ADO.NET code to persist the data in the database, it should be noted that we have not written a single line of code thus far. We have relied on SharePoint list handling and content database to implement the list.
But imagine if we are required to extend the above functionality. For example, it is required that each item of the list be secured individually. Users also want to subscribe to any changes to the list (new recordings) made to the list either via RSS or email. From a QA standpoint, a content management process needs to be enforced when a new webcast recording is uploaded requiring versioning, check-in/check-out, and approval workflow. Content management requirement invariably necessitates the ability to maintain an audit trail of changes as well as the ability to undelete an item that was inadvertently deleted. Last but not the least, a search function on the site should include the information about the webcasts.
Now with the need for additional features, the custom ASP.NET solution is not easy. Fortunately, all of the above functions are provided by SharePoint List by default. We can even extend the SharePoint List behavior using event handlers.
All of the information stored inside a list is accessible, not only via the SharePoint UI, also via the Object Model (Class Library as well as Web Service based OM). This means that processes outside the host process can access the list information – a key to building transparent applications that are reusable.