Patrick’s Bytes

Techie for the past 30 years…

MOSS 2007 BDC Definition Editor gotchas

What is Business Data Catalog(BDC)?

The BDC is essentially a catalog of business applications that are of interest to SharePoint Server 2007 users, and it bridges the gap between the portal and business applications by bringing in key data from various applications to SharePoint sites, lists, search, and user profiles. The BDC is the key infrastructural component around which most of the other business data features of SharePoint Server 2007 are built. Administrators can register business applications in the BDC, after which the data in the application is immediately available to SharePoint through the business data features described below. A key requirement for each registered business application is an XML-based metadata model that describes the application programming interfaces (API) of the application or the schema of the database that maps to business objects (e.g. customer) and properties (e.g. name) that a SharePoint user can understand. These metadata models can be easily created by DBAs or database developers.

For example you can expose a table in a SQL Server database

image

On to a Business Data List webpart in MOSS 2007.

image

Creating an application definition use to be a pain because you have to define every properties and entities inside a XML file without the help of any tools. Then came BDC Man to over this problem but it comes with a pocket burning price tag. So somewhere early this year, SharePoint SDK update includes a simple BDC Definition Editor. Now you can have (almost) all the features found in BDC Man for free!

Connecting to a database is easy, fire up DBC Def Editor

image Click on Add LOB System

image On the Add LOB System window, you can connect to a DB or Webservice, for this I click on Connect to Database

image Key in the connection string and click Connect

image After that on the right you can see 2 new buttons, I click on Add Table to bring in a table now

image I select the table Currency and drag in over to the blue blank space.

image For this I going to use 1 table only, so I click at the bottom.

image Name it as ‘currency’

image  Now the definition has been created. Logically I can click Export and upload it to MOSS. The exported Application Definition is a XML file shown below

[sourcecode language='xml'] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation="http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog BDCMetadata.xsd"
type="Database" version="1.0.0.0" name="currency"> localhost simpledb True SqlServer PassThrough Text Select “Name”,”Description” from Currency where Name=@Name Text Select “Name” from Currency
[/sourcecode]

Imagine you have to do this manually even for a single database table!!

 image

So now go to your Shared Service Admin site to upload the def file.  Click on Import application definition

image Choose the file and click Import on the next screen.

image  There you go, no problem reported.

image

So now with the app def imported I go back to my SharePoint site to add the Business Data list webpart.

image

To bind my Currency table to the part, I open up the webpart editor. At the Type textbox click on the telephone book icon.

image

To my surprise, when I open up the Business Data Type Picker, it reported There are no Business Data Type loaded in the Catalog! So what went wrong? The Currency Add Def indeed imported.

Actually the def editor left out a couple of things which need the user to manually configure which I found out later.

image

First one, the Business Data List webpart uses a Finder method instance of the app def to list the data. The def editor by default only create the SpecificFinder and the IdEnumerator method instances.

image

To verify this, open up your Event Viewer and you will see errors in Application log.

To create another method instance, right click on Methods and click Add Method

Change the name of the new method to List

image

On RdbCommandText, copy the one from the SpecificFinder but remove the where clause

Then add a new Return parameter. Right click on Parameter and choose Add Parameter.

Change the name to @Currency

image

Now right click @Currency and select Create Root TypeDescriptor

image

Cut the story short, you now continue to construct the parameter as per the one on Find_Currency method. Only thing is you do not need to create the input parameter @Name.

image

Right click Instances and choose Add Method Instance, select the radio button ‘Finder’ on the Create Method Instance window. The Return TypeDescriptor should be Reader.

image

After that go over to Currency Entity, fill in the name of the Title field. The purpose of the Title field is to tell MOSS later which column to display the action menu.

Having mentioned action menu, I won’t be created any Action for this entity but instead use the default ‘View Profile’ action menu.

image

Now update the version number to 1.1 else BDC will complain version conflict. After that export the definition to xml file and import it to MOSS.

image

Double confirm the version number is 1.1 now.

image

Then go back to my SharePoint site, funny thing is now you need to remove the blank web part and insert a new Business Data List webpart. Then open the webpart editor and you will see your Currency table there.

 

image

Add that to the editor and exit the edit mode. You can now see the Currency table listed here.