1

I am pretty new to SharePoint and I am trying to customise the search in a SP site that I did not create myself.

I downloaded a Display Template off the Internet, which shows the search results in a tabular format. It's working properly but it shows 5 columns and now I want to change these columns to other custom properties.

I figured I must check the managed properties. I checked the columns I want to populate, e.g. ClientName, CustomerVatNo and I found these as managed properties: ClientNameOWSTEXT, CustomerVATNoOWSTEXT respectively.

So I tried to replace these managed properties, but I can't see anything when I search for something. When checking for the 'results' in their actual original view, the fields work, so I must be missing something.

<a href="_#=ctx.CurrentItem.Path=#_">_#=ctx.CurrentItem.Title=#_</a>

The above works

_#=ctx.CurrentItem.ClientNameOWSTEXT=#_

But the above doesn't.

I also checked the settings of the managed properties:

This is the one that works This is one that doesn't

Appreciate any help.

  • Have you added these custom managed properties to the display template? You have to add them explicitly in the top of the display template section. Let me know and I can add details. – Ransher Singh Jul 27 '16 at 17:29
  • When you say at the top of the display template section, where exactly? The only place I can think of is when uploading the 'item' html it asks me for Managed properties and there already around 20 there, just not the ones I need. They go in this format: 'xxx':'xxx','yyy':'yyy'. Are you referring to that?? I tried that and I still was getting nothing. If any other thing, I'd appreciate you specifying. Thanks a lot! – Jurgen Cuschieri Jul 28 '16 at 6:41
1

Put your managed properties in Display Template ITEM (inside _catalogs/masterpage/Display Templates/Content Web Parts/filename_Item.html) under ManagedPropertyMapping

<mso:ManagedPropertyMapping msdt:dt="string"> </mso:ManagedPropertyMapping>

For example

Add these two properties

<mso:ManagedPropertyMapping msdt:dt="string">
'Client Name'{Client Name}:'ClientNameOWSTEXT',
'Customer VAT No'{Customer VAT No}:'CustomerVATNoOWSTEXT ',...

And then it will work when you call it for example

_#=ctx.CurrentItem.ClientNameOWSTEXT=#_
  • @Jurgen I meant this example above..Does this not work? – Ransher Singh Jul 28 '16 at 13:17
  • @RansherSingh Just deleted my previous comment. The method works and I didnt need to define the name of the column like this: 'Client Name'{Client Name}:'ClientNameOWSTEXT', in fact, this was enough: 'Client NameOWSTEXT':'ClientNameOWSTEXT'. However, it did not work for 4 of the fields (from the 10 I needed). 2 of them are not found from the list of Managed properties (In Site Settings/Search Schema), the other 2 are found but are not being retrieved. Any idea what I should look for? – Jurgen Cuschieri Aug 5 '16 at 6:44
  • Go to your search schema, CA --> Search Administration --> Search Schema and make sure that these properties are retrieved when you search for them under Managed Properties. If not, add them. If yes, open each property and make sure it is check boxed as Searchable, Retrievable etc.. – Ransher Singh Aug 5 '16 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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