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:

[sourcecode language=”csharp”]

static void Main(string[] args)
{
SPSite site = new SPSite(“http://server:port/sites/sitename”);
BdcService service = SPFarm.Local.Services.GetValue();
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();

[/sourcecode]

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.

About Karsten Schneider 312 Articles
Consultant for Microsoft 365 Applications with a strong focus in Teams, SharePoint Online, OneDrive for Business as well as PowerPlatform with PowerApps, Flow and PowerBI. I provide Workshops for Governance & Security in Office 365 and Development of Solutions in the area of Collaboration and Teamwork based on Microsoft 365 and Azure Cloud Solutions. In his free time he tries to collect tipps and worthy experience in this blog.

Be the first to comment

Leave a Reply

Your email address will not be published.


*