Office 365 – SharePoint Online – Out of the box is good but sometimes not – OWS_URL

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.


Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Related Posts

Leave a Reply

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

Discover more from SharePains

Subscribe now to keep reading and get access to the full archive.

Continue reading