Implementing a Custom Property Type


It seems that on every SharePoint implementation, the customer invariables asks to incorporate some data that is managed by a different system. The second reason is that going through this exercise exposes you to a wide range of technical details. We will only provide as much detail as needed for implementing a custom property type for document libraries. So, for the remainder of this chapter we are going to use an External Data Lookup model as an example of a Custom Property Type. As you are reading, note that you will be exposed to many other starting points to many other problems that should be pretty easy for further exploration on your own. In other words, from this exercise you will be able to recognize and tackle other problems using this as a catalyst.

Author Lookup

Looking at the pubs database that ships with SQL Server, we can create an example that demonstrates keeping data in some other store rather than SharePoint. Suppose you wanted to store contracts and other information related to an author. SharePoint is a document repository and serves as a fine tool for this project. It sure would be nice to keep the dynamic data that is stored in SQL Server available to a property when a user adds a document to a document library.

How It Works

There are several different ways that we could make this work. The business requirements will dictate the way that is best for you. In this case, the business requirements dictate a demonstration of how to make a custom property, so we are going to shoot for something simple. An HtmlSelect element displaying the authors with the author IDs as values will suffice. In this case, let's assume that our business rule states there will be only one author bound to a document.

If this were an actual business problem, it's only obvious that we would have to enable multiple authors per document. One way would be to use two multi-line select boxes with an arrow button in between to indicate moving an author from one list to another. If there were a large number of authors, it wouldn't make sense to list them all at once. In this case, you might want to perform a search for an author and present the user with a list to choose one or more authors. Whatever you can do in an ASP.NET interface, you can also do in this solution.

Our example is just going to be a select box that is populated with a list of authors. The user will choose one author, and the selected value will be stored in a single line text field. Our example will also demonstrate how to set the text color. Setting the text color will probably never be used in the real world, but the techniques will certainly be used. This will demonstrate how to pass data back to your control and most importantly how to save custom settings for display or functionality.




SharePoint 2003 Advanced Concepts. Site Definitions, Custom Templates, and Global Customizations
SharePoint 2003 Advanced Concepts: Site Definitions, Custom Templates, and Global Customizations
ISBN: 0321336615
EAN: 2147483647
Year: 2006
Pages: 64

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net