SharePoint 2007: BDC - The Business Data Catalog
This post is in continuation to a series of blogposts I put up on BDC - the Business Data Catalog.
Table of Contents:
Lists with Business data type columns
Other custom applications targeting a common runtime object model.
Making it easier to author XML Applications: BDCMetaMan
So, as I just described, BDC is a way to bring external data into MOSS
. Anything that can be accessed using ADO.NET or a Web Service, can be brought into MOSS using BDC.
Right after that, I demonstrated using a simple Hello World example of how I can use BDC to pull in information about a single customer instance from Northwind.Customers sitting in a SQL Server 2005/2000 database.
But then, how good is this "List" that contains only one entity? Shouldn't it be a collection?
In this blogpost, I am going to extend that application (i.e. mostly modifying the Xml Goo you saw in this blogpost), so it can fetch me a number of entities back. A good example would be, bring me all entities (i.e. Customers) that live in a particular City.
The changes are pretty easy,
- Start with the XML Goo you already used here.
- Modify the Method "GetCustomers", change the RdbCommandText to this -
SELECT CustomerID, ContactName, Address, City FROM Customers WHERE City like @City
- Right below that, Remove the FilterDescriptor for CustomerID, and replace it with the following FilterDescriptor
<!-- Define the filters supported by the back-end method (or sql query) here. -->
<FilterDescriptor Type="Wildcard" Name="City" >
<Property Name="UsedForDisambiguation" Type="System.Boolean">true</Property>
- Change the Parameter CustomerID (direction "in") from CustomerID to City as shown below -
<Parameter Direction="In" Name="@City">
<TypeDescriptor TypeName="System.String" IdentifierName="CustomerID" AssociatedFilter="City" Name="City">
<DefaultValue MethodInstanceName="CustomerFinderInstance" Type="System.String">%</DefaultValue>
- Yeah that's it ! :-)
Now go ahead and redeploy the application to the Shared Service Provider using the following steps
Go to the SSP
Click n Business Data catalog//view applications --> Delete the previous application (or you could also version, but I'm gonna be lazy and consistently lazy)
Click on Business data catalog//import application definition
Browse to the Xml Goo as your "Application Definition File", choose to import as a "Model", and hit "Import"
You should again see the "Profile Page Creation Skipped" message. (For explanation, see this blogpost)
Your BDC Extended Hello World is ready to eat. You can use it in the following manner -
- Go to your favorite sharepoint site.
- Edit a page that accepts webparts.
- Add a webpart called "Business Data List". If you created this site using the Blank Template, you will need to first go and enable this webpart in the webpart gallery (Site Actions --> Site Settings --> WebPart gallery).
- When you add the WebPart, it'd look like this -
- Do exactly that, Click on "Open the Tool Pane" (or you can also "Modify Shared Web Part" under the Edit menu).
- In the tool pane, put in "Customer (NorthWindTraders)" under the "Type" text field. It's better if you use the finder button, so there are no typos. Mine looks like this -
- Hit "OK" at the bottom of the page, and your webpart should look like this now -
- Click "Exit Edit Mode", and type in a City of "London" (or whatever else you please), hit "Retreive Data" and assuming you actually followed all I wrote in this post above properly, you should see results in your BDC webpart as shown below -
But, whats up with the "Profile Page Creation Skipped" message? And what if I wanted to actually view details of a particular entity? Heck, how do I actually use the above data?
For all of that, you need to add a "Specific Finder" method. That's comin' up next.