The Document Information Panel (DIP) that is provided throughout the Office 2007 client applications for updating metadata is very useful when assigning meta data to your documents. I have always been a big fan of it, as I find that in Office 2003, users rush the inputting of data into documents as they are prompted upon saving the document for the first time. Often at a point when they are heading out to lunch or going home! So to be prompted immediately upon creating a document is useful and leads to less mistakes. The Document Information Panel also compliments the powerful functionality of Content types within SharePoint 2007 allowing different Panels to display depending upon the type of document created. These DIP’s let us down in two areas though. They do not support custom Field Types, and they also only provide a Text Input Box for the identifier when using a Business Data Field Type. For instance, Imagine that you have created a Proposal Document Library to store Customer Proposals in. You use your Line of Business System to provide the available data, and have therefore exposed the Customer Entity for use in your document library by creating a Business Data column to store the Customer ID. The issue is that the Customer ID alone is not much use. For example not every sales person would know that the ID ALFKI relates to Alfreds Futterkiste especially if you had thousands of customers. The problem with the Document Information Panel only providing a text box is illustrated below:
As you can see, in order to retrieve the Company Name, Customer Address, and City a valid Customer ID must be manually entered. The document information panel does not offer any form of lookup.
This problem can be easily solved though by using Microsoft Office InfoPath 2007. InfoPath can be used to provide a new Document Information Panel which replaces the old one. When creating the Document Information Panel within InfoPath, you are able to base it upon the XML Schema that makes up the document library. This makes all of the Document Library Columns available to you as Controls within the InfoPath form. To create the InfoPath form, follow these steps:
1. Open Microsoft InfoPath 2007
2. Select ‘Design a Form Template’
3. Choose XML or Schema, and click Ok
4. Type the URL for your Proposal List e.g. http://win2k3/bdc/Proposals/
5. Click Next, and then choose Document (Document is the Content type used in your document library)
6. You should end up with the Document Information Panel opened up in InfoPath.
The form will look almost identical to that of the original Document Information Panel, and the Identifier column will still be just a Text Box. However, we can now manipulate this form! The first task will be to convert the Text Box control for the Customer ID field to a Drop Down List type control showing the Company Name column, but still storing the Customer ID for the selection. To do this, simply right click the Customer ID Column and choose ‘Change To’ -> Combo Box.
Once you have changed the control, we need to set the properties to allow the control to be populated with choices. Edit the properties of the newly converted control. Upon doing so you will be presented with options on how to populate the control e.g. Lookup the values or enter them manually. We are going to lookup the values. There then lies several more choices! How exactly do you want to get at your data? Well, you could link to the database directly if you use SQL or Access according to the Wizard, or you could use a Web Service. Since we have already made use of the Business Data Catalog here, we could make use of it again by creating a simple Web Service that exposes the Customer Entity data. The choice is yours but writing the Web Service would make sense as you could use it time and time again and would not have to change your code if you changed the underlying Application Definition File or Database Table. In other words, there would be no hard coded connection strings or anything like that to maintain. There are some very good examples on how to write your object model code using the BDC Object Model within the sdk:
You can then step through the wizard pointing it at your web service and method that returns the data as shown below.
Once you have configured the Web Service, and entered any input parameters that are required, you will be able to finish the job by specifying which columns returned from your web method provide the display value and the stored value. For this particular instance, we require the value to be Customer ID, and the Display Name to be Company Name as is shown below:
The finished result will look like the below when it is being previewed which now provides your users with the Drop Down List where they can choose the required customer rather than take a wild guess at the customer id.
When you are finished in InfoPath, the form will need to be trusted. The trust can be setup within Form Options which involves the creation of a certificate and so on which will need distributing to your client computers. Looking up external data is not allowed in the existing standing InfoPath Form settings.
The last thing to do is publish the form. The form is published back to the documents library. All you need to do it click the Office Button, and then choose Publish. You should then find that you have a fully functional Document Information Panel.