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

In general I try to use out of the box functionality in SharePoint but sometimes out of the box just doesn’t work.

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.

Advertisements

Please leave a comment or feedback

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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