Question

I've added a Search Content Source for my BDC application, and results are populating correctly. So far, so good! I don't really like the way the results get displayed, though.

Problem 1: Result Titles

The title of the result is always the file name of the profile page. Obviously, since every item of a type has the same profile page, this isn't really helpful. Is there a way for me to change what's displayed there? Ideally, it would be a combination of a few different fields on the item, such as First Name + Last Name.

Using the screenshot below as an example, I'd like to change the link that says Customer_1.aspx, right above the content snippet.

Example SharePoint search result

Problem 2: Text snippets

Is there a way for me to force the Search result to display certain fields from the item? In this example, for a contact search, maybe I would want to show their phone number and email address right away, to save the user from having to click through and wait for the profile page to load just to get basic contact info.

Update: Result Type

I've been researching this most of the day, and I've learned that I need to create a Result Type for my external content type. Once I have that, I can create custom display templates. I've tried this a bunch of times, but I still can't seem to get it working.

I've created a managed property on one of the columns (a non-null integer that is only on this record type), but I've not found a property match setting that will work. Any suggestions?

enter image description here

Was it helpful?

Solution

The solution is to create a new Display Template that includes the BCS fields as Managed Properties. You have to add the Managed Properties in the Search Service Application under Search Schema, and then do a full crawl.

Copy an existing display template and then add your managed properties and rendering logic so it looks the way you want.

You can follow this guide: http://www.ableblue.com/blog/archive/2013/06/05/introduction-to-sharepoint-2013-display-templates/ For debugging: http://www.ableblue.com/blog/archive/2014/03/01/create-a-diagnostic-display-template/

For the Result Type you have a couple choices, probably the easiest is to create a result source. You can create a result source that includes just the entities from BCS. The results will be associated with the ContentType from your BCS Entity. In my case the BCSEntity is "Customer" (because I have a Customer Entity in my BCS Model). This way I create a Result Type rule and apply it to my Result Source. It looks like yours will be something like ASICustomer.

Another alternative is to create a rule like ASICustomerNumber contains "1,2,3,4,5,6,7,8,9,0"

OTHER TIPS

Solution to problem 1 (and maybe 2 too)

You have to configure the External Content Type Profile Page Host To do it you could follow this guide http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/04/15/how-to-create-a-bcs-profile-page-in-sharepoint-2010.aspx

I hope that this can help you.

RE: the OP question #1,"How do you display a managed property in place of the Title field (profile page name for BDC ECTs) in the display template?" (paraphrased).

Based on reading Matthew's and Bella Engen's various blog posts on this topic I see two possible solutions. I have not yet implemented either one.

  1. Modify Item_CommonItem_Body.html to replace the Title field output. This common display template is called from your display template by the line _#=ctx.RenderBody(ctx)=#_
  2. In-line the code from Item_CommonItem_Body.html into your display template replacing the line _#=ctx.RenderBody(ctx)=#_

For (1), in Item_CommonItem_Body.html modify the line var titleHtml = String.format(...); to output the desired managed property. Of course this affects many display templates in the search centre. This may not be what you want.

For (2), if you have multiple result types thus multiple item display templates you will have to in-line the code multiple times.

Neither of these is a great solution.

Refer to Matthew's blog starting from Introduction to SharePoint 2013 Display Templates and Bella's blog series How to change the way search results are displayed in SharePoint Server 2013

RE: the OP question #1 redux, I did more research and found what is likely the preferred solution for 80% of cases. I left my other answer in case the details are useful for the other 20% of casses.

To recap, "How do you display a managed property in place of the Title field (profile page name for BDC ECTs) in the display template?" (paraphrased).

Answer: For BDC / search scenario, map the managed property Title to the crawled property corresponding to the desired entity field.

  • Start by browsing to your search service application
  • Open Search Schema > Managed Properties
  • Filter to properties that contain "Title"
  • Edit the "Title" property

enter image description here

  • Add mapping to the required crawl property(ies)

If you need a crawled property for an aggregate of entity fields, instead create a composite field on the entity because only a single crawled property value will be mapped.

enter image description here

  • Recrawl
  • Recrawl again

I found that the managed property and search results (display template) did not render the correct value from the crawled property until after a couple of crawls or a few hours later. Not sure why.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top