Posts Tagged ‘bdc’

Troubleshooting BDC Associations and Related Data List Web part

Tuesday, June 22nd, 2010

I’ve been working with the BDC and a proprietary CRM system to bring data about sales history into SharePoint. I’ve been using the basic BDC tool – Business Data Catalog Definition Editor – that is bundled with the SharePoint SDK. It’s very basic, and there are one or two commercial products out there, but it just about does enough, and is free, after all. It enables you to define the entities, relationships and methods, and test them, within the tool. The error reporting is moderate – you’re informed about the major issues, but, some errors only appear when you’ve imported the ADF and are actually working within the SharePoint environment.

I encountered one such error working with Business Data Lists, and, more specifically, Related Business Data Lists. The error manifests in two forms. This error message is displayed in the web part:

The Business Data Catalog is configured incorrectly. Administrators, see the server log for more information.

And if you check the event log on the server:

A Metadata Exception was constructed in App Domain ‘/LM/W3SVC/xxx/Root-x-xxx’. The full exception text is: Could not find appropriate places on the root TypeDescriptor to read sub-identifier values for the Instance of Entity ‘xxx’

You will have likely encountered this error before whilst developing the ADF. It’s essentially saying: “I’ve selected all this data from the database, but I can’t find the correct places on the return type, so I’m not sure what to do.” What’s infuriating about this is that if you try your method in the BDC DE, it will work fine. So it’s a bit of trial and error to work out exactly what it’s complaining about. So here are some notes and things to check/try:

  1. The method with the error is the one that with a MethodInstanceType of GenericInvoker.
  2. If you defined the Association (i.e., the tables to join together) in the BDC DE using the design surface, and your database is configured correctly with the foreign keys, etc. (which it will need in order to determine the relationship), then the method name will probably start FK_ followed by 2nd_entity_on_1st_entity, e.g., FK_orders_customer
  3. I read elsewhere that “identifier which is used in order to call the method in one entity, same identifier should also be present in other entity” – what this means is in your Associated data (what I’m calling “target” data) you must have one parameter which uses the identifier from the “source” data in its Type Descriptor (see attached image, red boxes)
  4. I took (3) a few steps further and ensured that the name of the parameter and TypeDescriptor in each entity were identical (attached, green boxes)
  5. I also assume that this is true of any method in source that is calling the target, that is, you’ll most likely be calling the target from your Finder method, which is the method you use in a Business Data Item / Business Data List webpart. The BDC DE does not create the Finder method for you – you have to create it manually. If you wanted to be able to add the Associated data to any of your other methods, you’d need to ensure (3) & (4) above, although I’m not familiar with any circumstances where you’d need to do this.
  6. Ensure there is an item on your TypeDescriptors for the return parameter for each of the entity identifiers. By default, BDC DE creates a structure of Parameter > OutParamName > Reader > Record. If your entity as two identifiers called “ref” and “number”, make sure that under Record, there is at least a TypeDescriptor for “ref” and “number” which link to the appropriate identifier
  7. Deploying and testing your ADFs is a bit of a rigmarole. The BDC will let you upgrade existing applications, but since it uses a cache, timer jobs and various other things in the deployment, you can never be quite sure if your new version is “live” – it is possible to delete the existing application, refresh the webpart page until you see an error, then install the new version, although this is time consuming and a very brute force approach!
  8. The name of the TypeDescriptors in your Record relate to the name of the column returned by the database – but if you want things to be more descriptive you can use aliases in the query, and reference those in the ADF

Hopefully that’s of some use. If you’re using the BDC on a very regular basis, it’s undoubtedly worth investing in a decent BDC tool, such as the BDC Meta ManBDC screenshot.

Set SharePoint BDC field value programmatically in Visual Studio workflow

Wednesday, June 16th, 2010

The Business Data Catalog (BDC) in SharePoint is a superb way of hooking up virtually any disparate system to SharePoint 2007. By defining the connection in to the system, you can expose any part of the system to SharePoint, and harness some of SharePoint’s real power – for example, its powerful search capabilities. Once you’ve created your connection (your Line Of Business [LOB] system), you can attach BDC columns to any list (e.g., document library) and you can, for example, have a document with a reference to your other system, so that you can permanently associate extra data to your document, without having to reproduce the information in SharePoint and create unnecessary duplication.

Using the BDC is beyond the scope of this post, but I’d like to cover an issue that I recently encountered when trying to work with the BDC and a document library. I had a fairly simple Visual Studio 2008 workflow that ran when a new item was created in the document library.


Business Data Catalog tips, hints and errors

Tuesday, July 14th, 2009

A few tips/hints from my experience in working with the Business Data Catalog Definition Editor to create line of business (LOB) application definition files for use in Sharepoint MOSS 2007.

1. Create a SpecificFinder method – by default, BDC DE doesn’t create a SpecificFinder method. You’ll need one for use in Sharepoint. More here.
2. Wildcard search – When creating a Finder method (for use with e.g., a Wildcard search) make sure the wildcard character is defined – which is done in the very topmost node of the tree (i.e, the LOB node.) Without it you might find the query runs, you just get no results. Where you’re using SQL Server, the Wildcard character by default is %.
3. Multiple Finder methods – You can create multiple filters on a single finder method, just make sure you specify default values and update your e.g., SQL select statement so instead of e.g., where name like @name you change it to where name like @name and date_create > @date_create_gt… etc.
4. “Provided stream is invalid” – If you get this error “The provided stream is invalid (not of type IDataReader, IEnumerable or IEnumerator). Parameter name: rawAdapterEntityInstanceStream” first thing to check is that your return parameter is the last one physically specified in your file.. i.e., you can have multiple in parameters, but the return parameter has to be last in the list. The way to fix this is export your application definition file (to XML), then manually adjust the order of the parameters, then reimport to BDC DE.
4a. Note: If you make manual changes to your ADF file and want to reimport to BDC DE, you have to delete the original definition from BDC DE first.

For reference, there’s a really good series of articles on basic BDC stuff, right about here.