Okay some time has passed after last post but now I have something pretty interesting in my mind. Lately I have been digging SharePoint 2010’s External List and External Content types (Business Connectivity Services, BCS). I need to make my own webpart (Visual Web Part or the regular one) that makes use of the picker that Microsoft uses when you set up your list with either directly External Content type or through lookup field to External List.
From the background I knew instantly that this will be tricky one (due to fact that External List Items are not like SPListItem’s and enumerating external list from code requires bits and pieces of extra with user security and so on).
If you look standard SharePoint 2010 edit form page with developer tools (in IE9) you’ll see that in UI there is mention about the SPFieldBusinessData. Now if you try to search with that term you’ll find pretty much nothing and Visual Studio does not help you either. At first I was hoping that yes it is like regular field in SharePoint but no luck.
After digging more I found some intresting posts about setting up ItemPicker with ExtendedData. Through UI this looks exactly same as the normal SharePoint’s External Item Picker but requires quite good amount of work setting up the ExtendedData. Also I found this not so appealing since in List we have done work already by defining External Content Type and some more properties.
So the search continued to next solution. After digging more into this I found quite nice solution at the moment for this problem. From some forum posts I found references to BusinessDataFieldControl (Microsoft.SharePoint.WebControls -namespace). If you just put this control to your page you’ll end up getting error about the null controls. This was not a good sign. However now there are big thanks to IntelliSense: from that control you can find properties like ItemId, ListId and FieldName. After setting those three properties you’ll get the control showing up and it works when picker dialog is opened (that nice “instant search” by giving some values to control is not working just yet). This was exactly the easy solution what I was looking for but however there are some limitations currently present.
Although I am still considering about using ItemPicker or keep still on searching for the perfect solution. With BusinessDataFieldControl you can find the data from external source but you can get only one line back at the time (let’s say that you have given the external column to show Company from external source and when you pick the company from dialog you just get the company and nothing more).
The search continues…