Thursday, April 24, 2008

Error with SharePoint BDC

I recently got the error :
"Application definition import failed. The following error occurred: The IdentifierName Attribute of the TypeDescriptor named 'FirstName' of the Parameter named '@FirstName' of the Method named 'GetCustomers' of the Entity named 'Customers' does not match any of the defined Identifiers for the Entity. Error was encountered at or just before Line: '57' and Position: '16'."
When trying to import a BDC schema into MOSS 2007.

It turned out that I'd forgotten to add the following line to the <Identifiers>
<Identifier Name="FirstName" TypeName="System.String" />

Following that fix I get the next error:
"Application definition import failed. The following error occurred: The AssociatedFilter Attribute of the TypeDescriptor named 'FirstdName' of the Parameter named '@FirstName' of the Method named 'GetCustomers' of the Entity named 'Customers' does not match any of the defined FilterDescriptors for the Method. Error was encountered at or just before Line: '57' and Position: '16'."

So I added the lines to the <FilterDescriptors> tag:
<FilterDescriptor Type="Wildcard" Name="FirstName" >
<Properties>
<Property Name="UsedForDisambiguation" Type="System.Boolean">true</Property>
</Properties>
</FilterDescriptor>

Following that, I got another error after successful installation of the schema into SharePoint when the User attempted to run the webpart. "The Business Data Catalog is configured incorrectly. Administrators, see the server log for more information.". That error is found within the Servers Event Log:
"A Metadata Exception was constructed in App Domain '/LM/W3SVC/1959965621/Root-2-128667808042048704'. The full exception text is: Could not find appropriate places on the root TypeDescriptor to read sub-identifier values for the Instance of Entity 'Customers'"

The fix for this was because I forgot to add the "IdentifierName="FirstName" to the TypeDescriptor tag.
<TypeDescriptor TypeName="System.String" IdentifierName="FirstName" Name="FirstName" >
<LocalizedDisplayNames>
<LocalizedDisplayName LCID="1033">FirstName</LocalizedDisplayName>
</LocalizedDisplayNames>
<Properties>
<Property Name="DisplayByDefault" Type="System.Boolean">true</Property>
</Properties>
</TypeDescriptor>

So the rule of the game when using the SharePoint BDC is watch your XML when adding new fields to a query..