In general I think that it is good to use out of the box functionality in SharePoint. Sometimes however, out of the box just not good enough.

quicklinks

Today I created a list with URLs and I used the out of the box field URL. SharePoint created a Managed Property for me called OWS_URL.

OWS_URL

So all is still good.

Then I created an item display template and updated my ManagedPropertyMapping

<mso:ManagedPropertyMapping msdt:dt=”string”>’Title’:’Title’,’OWS_URL’:’OWS_URL'</mso:ManagedPropertyMapping>

then I’m collecting the title and the URL field in my JavaScript:

var title = ctx.CurrentItem.Title;
var url = ctx.CurrentItem.OWS_URL;

Finally I’m displaying my Title of the items with a link to the URL mentioned in the URL field:

<a href=”_#= url =#_”>_#= title =#_</a>

All easy so far, but …. it doesn’t work. I’m now getting a URL https:/ /mytenant.sharepoint.com/sites/dev/Pages/ which is the location of the page where my search result webpart is added to the page. When I check in my browser I’m finding that ctx.CurrentItem.OWS_URL is set to null.

Then I created a new Managed Property myself called MyURL

MyURL

And mapped it to ows_URL (I also ticked the boxes Searchable and Retrievable)

MappedMyURL

<mso:ManagedPropertyMapping msdt:dt=”string”>’Title’:’Title’,’OWS_URL’:’OWS_URL’,’MyURL’:’OMyURL'</mso:ManagedPropertyMapping>

Then I updated the JavaScript a bit:

var title = ctx.CurrentItem.Title;
var url = ctx.CurrentItem.MyURL;

And now my URL is appearing fine.

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: