SharePoint 2007: BDC - Extending the Hello World Example

Posted on 4/24/2007 @ 5:19 AM in #SharePoint by | Feedback | 23844 views


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:

  • Introduction
  • In-built Webparts
  • Lists with Business data type columns
  • Search
  • User Profiles
  • 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
    • <FilterDescriptors>

        <!-- Define the filters supported by the back-end method (or sql query) here. -->

        <FilterDescriptor Type="Wildcard" Name="City" >

          <Properties>

            <Property Name="UsedForDisambiguation" Type="System.Boolean">true</Property>

          </Properties>

        </FilterDescriptor>

      </FilterDescriptors>

    • 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">

          <DefaultValues>

            <DefaultValue MethodInstanceName="CustomerFinderInstance" Type="System.String">%</DefaultValue>

          </DefaultValues>

        </TypeDescriptor>

      </Parameter>

    • 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 -

    WOOHOO!! :-)

    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.

    Sound off but keep it civil:

    Older comments..


    On 2/23/2008 4:27:57 PM Mike said ..
    Have you posted an example that uses dates as the filter to allow the user to enter a date and filter by greater than, equals, etc? I thought this would be a simple change, but it hasn't worked for me yet...


    On 4/23/2008 8:45:46 AM Tim said ..
    I too am very intested in using a date filter. Could you please comment on Mike's question?


    Thank you.


    On 5/8/2008 12:45:12 AM Pavan said ..
    I have created the XML and uploded in shared pointer 2007. Now I am able to search for starts with and contains but i am not getting anything for equal to and ends with.


    iI used query as


    " SELECT CustomerID, ContactName, Address, City FROM Customers WHERE CustomerID Like @CustomerID


    On 7/28/2008 8:59:18 AM BR said ..
    @Mike and Tom: Have you already found an example for date filter?


    On 7/30/2008 3:24:59 AM Liliana said ..
    Hi, I also need an example of date filter? Did you found it? Can someone help us?


    Thanks,


    On 10/12/2008 4:43:45 AM MJ said ..
    I want to display the data in the Business Data List as a dropdown List, instead of having user provide actual search string.

    Basically what I want to do is that, when DataList webpart loads it display some information in the dropdown list and the user be able to select the item from the dropdown list and the other webparts display the value accordinly. Could you please tell how it can be done?


    On 11/12/2008 3:08:33 AM NLTC said ..
    Hi all you guys. What have I do if I want to change the display language criteria like: "is equal to", "contains"... to another display language. For example: Japanese, Korea...


    Thank you very much and I'm very grateful for all your helps!


    On 3/12/2009 9:48:02 AM Cyrel said ..
    I have a complex data type returned from a web service method. And basically I want to access a member of that Field to display. Does anyone know how I can access it? Below is the TypeDescriptor defenition for the field. This is in the 'Items' TypeDescriptor and the output is always 'BDC.Jobs' for that column

    <TypeDescriptor TypeName="BDC.Jobs,PeopleLobSystem" Name="Jobs">


    <TypeDescriptors>


    <TypeDescriptor TypeName="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Description" />


    <TypeDescriptor TypeName="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Id" />


    <TypeDescriptor TypeName="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Name" />


    </TypeDescriptors>


    </TypeDescriptor>

    I basically want it to display jobs.Name (the value in Name) and not 'BDC.Jobs'

    Thanks


    On 7/14/2009 5:40:50 AM MT said ..
    Helpful article. If anyone is struggling to get a "like" finder method working using the BDC definition editor (rather than just copying the XML goo from these articles) then make sure the WildCard character is specified at the top level (i.e., LOB node) is set. e.g., in SQL server it's %.