So, now you have built your BDC .NET Assembly Connector and even added write operations to it. The next big thing you would think is – Can I tell SharePoint to search this BDC model?
Of course, you can! But there are few things you need to do in your BDC model in order for SharePoint to crawl your BDC model.
The BDC model exposes operations or methods through which SharePoint is going to interact with the external data sources. In our previous example, we had 3 operations:
- ReadItem – Read Operation returning a single entity
- ReadList – Read operation returning a collection of entities
- Update – Write operation updating a single entity
So, when you want SharePoint to crawl the BDC model, we need to tell SharePoint which operation to use in order to gather the data.
The RootFinder Method
With the BDC models, we can set properties on operations, entities, LOB instances etc., that let SharePoint identify certain extra capabilities. If a finder method has its RootFinder property set, then SharePoint will know that it has to enumerate the entities to crawl.
In our sample, the ReadList method is going to return all the entities and thus we can set the RootFinder property on this method.
Switch to your BDC Explorer, and click on ReadList. In the properties, click on Custom Properties button and add the RootFinder property as in the screenshot below:
Name – RootFinder
Type – Select System.String from the dropdown
Value – x
Switch to the designer pane and click on the ReadList method:
In the BDC Method Details pane below, click on ReadList instance under Instances under ReadList method:
In the properties, click on Custom Properties button and add the RootFinder property as in the screenshot below:
Name – RootFinder
Type – Select System.String from the dropdown
Value – x
Remember, since we want the ReadList method to be the RootFinder, we are doing this. If you have any other method, you can set this property for that method instead of the ReadList method.
Setting the ShowInSearchUI Property for the Lob System Instance
Not only we need to set the RootFinder property for the specific finder method, we also need to set the ShowInSearchUI property on the LobSystemInstance to true. This will tell SharePoint that this particular LobSystemInstance should be used in Search UI. Unfortunately, currently this can only be done via code. Below is the code to set this property on the BooksListBdcModelInstance. Just create a simple console application and execute the following code. You need to add the BDC Admin Object Model references which are as follows:
NOTE: The following is only applicable for the current Beta 2 release which is publically available. Things might change in the later builds.
- Microsoft.BusinessData from C:WindowsassemblyGAC_MSILMicrosoft.BusinessData14.0.0.0__71e9bce111e9429c
- Microsoft.SharePoint.BusinessData.Administration.Client from C:WindowsassemblyGAC_64Microsoft.SharePoint.BusinessData.Administration.Client14.0.0.0__71e9bce111e9429c
- microsoft.office.sharepoint.clientextensions.intl from C:WindowsassemblyGAC_MSILmicrosoft.office.sharepoint.clientextensions.intl14.0.0.0__71e9bce111e9429c
static void Main(string[] args)
{
AdministrationMetadataCatalog catalog =
AdministrationMetadataCatalog.GetCatalog("http://demo2010a");
Model bdcModel=catalog.GetModel("BooksListBdcModel");
LobSystemCollection lobs = bdcModel.AllReferencedLobSystems;
LobSystem flatFileBDCModel = (from l in lobs
where l.Name == "BooksListBdcModel"
select l).FirstOrDefault();
if (flatFileBDCModel != null)
{
LobSystemInstance flatFileBDCModelInstance
= (from ls in flatFileBDCModel.LobSystemInstances
where ls.Name == "BooksListBdcModelInstance"
select ls).FirstOrDefault();
if (flatFileBDCModelInstance != null)
{
Console.WriteLine("Updating ShowInSearchUI property for " + flatFileBDCModelInstance.Name);
flatFileBDCModelInstance.Properties.Add("ShowInSearchUI", "true");
//flatFileBDCModelInstance.Properties.Remove("ShowInSearchUI");
flatFileBDCModelInstance.Update();
flatFileBDCModel.Update();
}
}
bdcModel.Update();
Console.ReadKey();
}
We are using the BDC Admin Object Model and:
- Connect to the SharePoint Site – change the site from http://demo2010a to your SharePoint site
- Get the Catalog – which is BooksListBdcModel
- Get the Lob System – which is again BooksListBdcModel
- Get the Lob System Instance – which is BooksListBdcModelnstance
- Set the property to true
Configure SharePoint Search
Creating the BDC Content Source
Go to the Search Administration in Central Admin – Central Administration | Application Management | Manage service applications | Search Service Application and create a new Content Source
Select the Content Source Type as Line of Business Data
Select to crawl selected external data sources and select BooksListBdcModelInstance
Select to start a full crawl and click OK. This will start a full crawl of the content source.
Wait till the full crawl is over.
Updating the Scopes
Now go to your scope where you want to include this content source and create a new rule to include this content source:
Click OK.
Wait for the scope to be updated. This might from few seconds to few minutes depending on the content (It took 18 minutes for me!) or You could start the update manually from the Search Administration page. Look for Scopes updates status in the System Status.
Perform Search
Once the content source is crawled and scopes updates, perform the search from the site. For our books entity, enter any ISBN number, say for example 0470099410 in the search text box and hit the search button.
You should see the search results showing up!
(Clicking on it will not take you to the list item though)
Clicking on it won’t take you to the list item because you haven’t created the profile page yet – see how to do this on the Lightning Tools blog post:
http://www.lightningtools.com/blog/archive/2009/12/04/bcs-model-in-visual-studio-2010-ndash-specificfinder-and-idenumerator.aspx
Environment am using SP 2013 :
As per above checklist ,i verified that all are assigned well i.e ShowInSearchUI,Rootfinder & am able to see BCS data populated when added as external list in web application but when i try adding a new data source => Line of Business Data it still says “There are no external data sources to choose from ” while adding a new content source in search.