in SharePoint 2010

BDC .NET Assembly Connector: Tame SharePoint Search to search your .NET BDC Entity

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:

  1. ReadItem – Read Operation returning a single entity
  2. ReadList – Read operation returning a collection of entities
  3. 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:

NameRootFinder

Type – Select System.String from the dropdown

Valuex

RootFinder

Switch to the designer pane and click on the ReadList method:

BookEntity

In the BDC Method Details pane below, click on ReadList instance under Instances under ReadList method:

ReadList Instance

In the properties, click on Custom Properties button and add the RootFinder property as in the screenshot below:

NameRootFinder

Type – Select System.String from the dropdown

Valuex

RootFinder

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.

  1. Microsoft.BusinessData from C:WindowsassemblyGAC_MSILMicrosoft.BusinessData14.0.0.0__71e9bce111e9429c
  2. Microsoft.SharePoint.BusinessData.Administration.Client from C:WindowsassemblyGAC_64Microsoft.SharePoint.BusinessData.Administration.Client14.0.0.0__71e9bce111e9429c
  3. 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:

  1. Connect to the SharePoint Site – change the site from http://demo2010a to your SharePoint site
  2. Get the Catalog – which is BooksListBdcModel
  3. Get the Lob System – which is again BooksListBdcModel
  4. Get the Lob System Instance – which is BooksListBdcModelnstance
  5. Set the property to true

BDCModel

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

Content Source Type Options

Select to crawl selected external data sources and select BooksListBdcModelInstance

External Data Source Options

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:

Scopes

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!

BDC Search Results

(Clicking on it will not take you to the list item though)

Write a Comment

Comment

Time limit is exhausted. Please reload the CAPTCHA.

  1. 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.