15 September 2009

BDC Application Definition Designer ShowInPicker Quirks

Today I was doing some work using the BDC Application Definition Designer for SharePoint 2007 and discovered some very odd behavior. My current project has me defining a business data catalog that points to our help desk work order system to gather categories for a list of knowledge base articles. I completed the design of my BDC application and deployed it into SharePoint, created a new column in my document library to pick the desired entity only to get the message "There are no Business Data Types loaded in the Catalog". Oddly, the data type was there prior to changing a single property on one of my type descriptors: ShowInPicker.

I had set this value on the name of the category since the default item displayed in the picker is the identifier of the entity. It is very difficult for users to pick a category when all that is displayed is a series of numbers, thus driving me to set the value of ShowInPicker to true for my category name field. So, I examined the XML created and discovered:

<TypeDescriptor TypeName="System.String" Name="CategoryName" DefaultDisplayName="Category Name">

<LocalizedDisplayNames>

<LocalizedDisplayName LCID="1033">Category Name</LocalizedDisplayName>

</LocalizedDisplayNames>

<Properties>

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

</Properties>

</TypeDescriptor>

I remove the line and imported the definition once more. Now my business data type showed up again. After searching, I discovered an article by Paul Galvin describing how to set the ShowInPicker value. In his article, I discovered another property that I wasn't including in my definition: DisplayByDefault.

I went back to the Application Definition Designer and added this under the properties node for my category name and exported the LOB definition. Again, I imported this into SharePoint and received the same error message - "There are no Business Data Types loaded in the Catalog". Upon exploration of the XML, I discovered the following:

<TypeDescriptor TypeName="System.String" Name="CategoryName" DefaultDisplayName="Category Name">

<LocalizedDisplayNames>

<LocalizedDisplayName LCID="1033">Category Name</LocalizedDisplayName>

</LocalizedDisplayNames>

<Properties>

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

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

</Properties>

</TypeDescriptor>

The new property had been added, but the order was different from Paul's, so I changed the order and imported the definition again. This time, everything worked as properly and I could view the category name in the picker.

Moral of the story: Use the Application Definition Designer to get you started in defining your BDC application definition and then go back to make tweaks like this by hand.

No comments: