SharePoint 2010 Make BDC Model searchable

We created some BDC Models to request external data and display in SharePoint. After deploying the Visual Studio solution you can see your BDC model in the central administration. It displays that the BDC model property “crawlable” is set to false. You cannot set it to true using the UI. If you use SharePoint Designer to create external data access, it is set to true by default. So the question i try to answer is how to set your BCD model in visual studio to set the crawalble property to true for deployment.

BCSSearch_5

Let’s go through it step by step.

Step 1:  Add property ShowInSearchUI

Double click on your BDCmodel.bdcm and open your BDC-Explorer in Visual Studio. Expand the tree till you find the entry below “LobSystemInstances”. Mark it and click on custom properties (collection) in the property pane.
Add a new Entry like in the Screenshot: ShowInSearchUI from type System.Boolean and the value true.

BCSSearch_1

But that’s not all in. Please look afterwords at the last step.

Step 2: Add Property RootFinder to Method Instance ReadList

Open the BDC-Method details and choose your ReadList below your instances. In the property pane click on the custom properties and add a new one with RootFile from type system.string and the value “x”.

BCSSearch_3

Step 3: Add a title property

This is only for displaying nice search results. If you do not set this property the search results will be displayed with the name of the BCS Profile Page as title which makes the search result confusing.

Therefore click in your BDC-Explorer on your Entity – in my case TrainingsEvents –  and then add a property to custom properties in the property pane. Add Title from type system.string with the value from your entity. Normally it might be Title, in my case it is called “Sitzungstitel”.

BCSSearch_4_Title

Step 4: Deploy

After deployment your BDC Entity should be crawable like in the screenshot.

BCSSearch_5

Step 5: ShowInSearchResult Property

I am not sure, but in my case the step 3 was not the only one which i had to do. I also created a console app which defines this property. The main function looks like this:



static void Main(string[] args)
{
SPSite site = new SPSite("http://server:port/sites/sitename");
BdcService service = SPFarm.Local.Services.GetValue<bdcservice>();
AdministrationMetadataCatalog catalog = service.GetAdministrationMetadataCatalog(SPServiceContext.GetContext(site));
Model bdcModel = catalog.GetModel("TrainingsEvents");
LobSystemCollection lobs = bdcModel.AllReferencedLobSystems;

LobSystem flatFileBDCModel = (from l in lobs
where l.Name == "TrainingsEvents"
select l).FirstOrDefault();
if (flatFileBDCModel != null)
{
LobSystemInstance flatFileBDCModelInstance
= (from ls in flatFileBDCModel.LobSystemInstances
where ls.Name == "CRMTrainingsEvents"
select ls).FirstOrDefault();

if (flatFileBDCModelInstance != null)
{
Console.WriteLine("Updating ShowInSearchUI property for " + flatFileBDCModelInstance.Name);
flatFileBDCModelInstance.Properties.Add("ShowInSearchUI", "true");
flatFileBDCModelInstance.Update();

flatFileBDCModel.Update();
}
}

bdcModel.Update();


After running this app i could see the bdc model at my content source:

BCSSearch_6

If you like to read more about or how to setup the project from scratch, i would like to recommend you this nice post

..:: I like SharePoint ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Pohnke About Karsten Pohnke
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.

Submit comment

Allowed HTML tags: <a href="http://google.com">google</a> <strong>bold</strong> <em>emphasized</em> <code>code</code> <blockquote>
quote
</blockquote>

Please fill in the captcha: * Time limit is exhausted. Please reload CAPTCHA.