Karine Bosch’s Blog

On SharePoint

Debugging the Display Template

I’ve been playing with Search in both SharePoint 2010 and SharePoint 2013 the last couple of days. It took me some time to get used to the differences in SharePoint 2013 but I have to admit that I’m really impressed about the new features of Search in SharePoint 2013. But this post is not another post on what Search has to offer in SharePoint 2013.

Today I had the Display Templates on my agenda. One of the things I tried out was adding a managed property to the <mso:ManagedPropertyMapping> element and it took me some time to figure out why I couldn’t render the value of that managed property.

This blog post explains how you can debug the ctx.CurrentItem  using Chrome but I used an alternative using the Developer tools of Internet Explorer:

  • Press F12 to open the Developer Tools.
  • Click the Script tab.
  • Select your Javascript file from the dropdown in the upper right corner of the screen. In my case this was the item_default.js.
  • Place a breakpoint right after the test on existence of the ctx.CurrentItem object.
  • Click the Start Debugging button.
  • Execute the search query again.

The debugger will stop at your breakpoint:

Debug Display Templates 1

In the Watch window you can verify the content of ctx.CurrentItem:

Debug Display Templates 2


July 16, 2013 - Posted by | Search, SharePoint 2013

No comments yet.

Leave a Reply

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

%d bloggers like this: