Thursday 20 January 2011

Business Connectivity Services - SharePoint 2010

There's a very good article on business connectivity services which puts you on the right direction to start things with it. But when a problem comes after deploying your external content type then you're left on your own. 

When I deployed my external content type the first thing I was encountered was the error message which says "Access is denied..." you can get around with this by setting the permissions in the central administration > Manage Service Applications > Business Data Connectivity Service > Set Metadata Store Permissions(make sure  you check 'Propogate permissions to all BDC Models option...'). When I got past through this stage the next thing waiting for me was this(as specified below).

"Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer."

Now there can be numerous reasons for this error message. Before you start pulling your hair with Microsoft SharePoint Designer my advice will be to have a look at the LOGS in (14 hive) folder.

Somehow SharePoint utilises windows communication foundation service to call and retrieve the data (my assumption: at-least that's what I saw in the logs). After series of svc calls I eventually managed to dig out the actual error message which was stopping the web part from showing the results. The error message in the log file was something like this 
SharePoint Logs:

"Error while executing web part: Microsoft.BusinessData.MetadataModel.InvalidMetadataObjectException: There is an error in the TypeDescriptor of Parameteers on Method with Name 'ReadList' on Entity (External Content Type) with Name 'ExternalUser' n Namespace 'ExternalUsers.BdcModel'. The TypeDescriptor incompletely define where the Identifiers of Entity 'ExternalUser' are to be read. That Entity expects exactly '1' Identifiers, but only '0' TypeDescriptor were found from which to read the value them.    at Microsoft.SharePoint.BusinessData.Infrastructure.CompositeIdentifier.GetIdentify()................"

After inspecting the error message I realised that this has something to deal with the identifier type descriptor which is not properly set in the return value of the ReadList method. 

My Entity looks something like this(I didn't have the decent software to grab the screen-shot):



When I reconciled BDC model, I found that the identifier property wasn't being set in the properties of UserId identifier type descriptor. This is actually to tell the BDC that the type descriptor specified in BDC model is mapped against this class attribute. The screen shot below shows more details.

Sorry note: Once again the quality of image is not that great. But just to give you an idea I've pasted this in here. I don't have facitlity to transfer stuff from my server machine to back into my laptop. 




When I did set the Identifier attribute to UserId of a class and redeployed the solution everything was gone back to normal and this time I got some results displayed in the web part too.

Majid








5 comments:

Aviw said...

Thanx!!
This is my case!

Anonymous said...

Excellent !! thanks a lot ! save my day

Unknown said...

good catch

Unknown said...

good catch

Unknown said...

good catch

Iconise ‘Add Picture’ control in PowerApps

Default look you get for ‘Add Picture’ control is not very appealing for end user and there is no OTB way of specifying icon for this con...