0

OnPrem 2013. I'm looking for a way to use a Custom Field as the Title (clickable link) in results of search. I have dug across the Internet and found many things that got me close. Here is what I tried so far:

  • Create Test Site, add custom field to DocLib as single line of text. Added docs and metadata.
  • Created sub-site with Enterprise Search template.
  • Created Results Set that only returns from DocLib. Tested... works.
  • Created a new Managed Property and mapped to Crawled Property ows_CustomField. (even copied options from Title ManProp) Reindexed site, Incremental Crawl.
  • Got into copy of Item_CommonItem_Body.html and added ManProp to mso:ManagedPropertyMapping.
  • Modified line 20 (as called out in many online articles) and referenced my Managed Property. No Dice.

I am able to switch the Title to other ManagedPropertyMappings already called out in the mapping such as Path, EditorOWSUSER, and more, so I know I'm doing something close. I just don't know why it doesn't like my custom ManagedProp...

For the record, I also tried adding the mapping the ows_CustomField to the 'Title' ManProp, and move it to the top hoping it would take this as the 'first non empty value'. No Dice.

Simply put, these work:

  • var title = Srch.U.getHighlightedProperty(id, ctx.CurrentItem, "Title");
  • var title = Srch.U.getHighlightedProperty(id, ctx.CurrentItem, "Path");
  • var title = Srch.U.getHighlightedProperty(id, ctx.CurrentItem, "DocId");

This does not:

  • var title = Srch.U.getHighlightedProperty(id, ctx.CurrentItem, "CustomManProp");

Hoping someone can point out what I'm doing wrong. Thanks!

1 Answer 1

0

You need add that managed property in item not in commonitem file. Find what item you want to change (inspect item on search results and find for ex.

name="Item" data-displaytemplate="WebPageItem"

Then go to

YOURSITE/_layouts/15/manageresulttypes.aspx?level=sitecol

and create copy of that item. Add that CustomManProp and save file. Go again to

YOURSITE/_layouts/15/manageresulttypes.aspx?level=sitecol

and clik update in ribbon.

And that's it. :)


EDIT

Default Word result type looks at Item_Word.html

Copy of word result type for ex. WordNew make it look at your Item_WordNEW.html

Edit Item_WordNEW.html and add your CustomManProp in <mso:ManagedPropertyMapping msdt:dt="string">'CustomManProp':'CustomManProp',...

You can call your property before _#=ctx.RenderBody(ctx)=#_ (RenderBody uses Item_CommonItem_Body.html to render)

<!--#_
    var customManProp = ctx.CurrentItem.CustomManProp;
_#-->
    _#=customManProp=#_
    _#=ctx.RenderBody(ctx)=#_

then go to YOURSITE/_layouts/15/manageresulttypes.aspx?level=sitecol and click update in yellow ribbon to view your custom managed property.

5
  • Hi @eVT, Thanks for the response! I'm still struggling a bit with the details. My items are Word Docs (data-displaytemplate="WordItem"), so made a copy of Item_Word.html file, and pointed to copy of word result type. Now in the html copy file, where am I putting the reference to CustomManProp? Tried mso:ManagedPropertyMapping, but didn't have an impact. (added ,'CustomManProp':'CustomManProp' to the end, and tried 'Title':'CustomManProp') Not seeing anything else intuitive. Thanks!
    – Steige
    Nov 22, 2016 at 15:33
  • go to YOURSITE/_layouts/15/manageresulttypes.aspx?level=sitecol and you click a Property Sync alert. blogs.technet.microsoft.com/tothesharepoint/2013/09/06/…
    – Marko Tica
    Nov 23, 2016 at 8:35
  • This was completed in both tries of: <mso:ManagedPropertyMapping msdt:dt="string">'Title':'CustomColumnProp'... and ...'CustomColumnProp':'CustomColumnProp' with no results.
    – Steige
    Nov 23, 2016 at 16:41
  • Can you be a bit more specific and complete... i.e. CustomManProp to be mapped to CrawledProp, this display template needs this line of code here, etc. Thanks again!
    – Steige
    Nov 23, 2016 at 16:48
  • i have updated answer.
    – Marko Tica
    Nov 24, 2016 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.