Azure / Office 365 / SharePoint Development / Search

Ultimate diagnostic display template

on Apr 28, 2014 by Elio Struyf with 20 comments

For my SharePoint Saturday Belgium 2014 session: "Sorry, something went wrong. How to start debugging your Display Templates", I created the ultimate diagnostic display template. With this display template you're able to retrieve all the available properties for your result.

Content Search Web Part Configuration

Content Search Web Part Configuration

When you configure the Content Search Web Part as shown above, it will output the property name, type and its corresponding value for the current result.

Output of the ultimate diagnostic template

Output of the ultimate diagnostic template

I also build in that it shows which of the values are null or empty. These values will be outputted like this:

Showing empty or null values

Showing empty or null values

Note: this display template is created for retrieving only one result.

Office 365 and future on-premises updates

The template currently only works on on-premises, in Office 365 you first need to do some changes to the list via PowerShell to make use of the template. This is because Microsoft did some changes on the list and libraries. More information can be found in a blog post of Mikael Svenson - Debugging Managed Properties using SharePoint Query Tool v2.

Download

The ultimate diagnostic display template can be found on the SPCSR GitHub repository: GitHub SPCSR Project.

To use it, download the HTML template and upload it somewhere in your master page gallery. Configure your content search web part as shown above, and you are good to go.

Feel free to give feedback about it.

Article comments

  • Pieter Temmerman

    Looks like a time saver! Certainly in combination with the SharePoint search query tool. Nice work Elio!

  • Pingback: Announcing #SPCSR - A community project - Blog of an overweight SharePoint addict()

  • Dmiry

    Thank you, Elio.
    Wonderful template!

  • Manoj Nair

    Hi,

    Some of our users are receiving this error on search results page where I have a custom display template. But this issue happens only on IE and not on Chrome.

    Is it possible to view a recording of this session so that I can see how to debug this?

  • Manoj Nair

    I added this display template to the search results webpart and I’m getting the following error:

    Display Error: The display template had an error. You can correct it by fixing the template or by changing the display template used in either the Web Part properties or Result Types.

    Unable to get property ‘length’ of undefined or null reference (CoreRender: ~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Ultimate_Diagnostic.js)

    Not sure if I missed out something.

  • got the same error and yes I have used the template from your link

    Unable to get property ‘length’ of undefined or null reference (CoreRender: ~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Ultimate_Diagnostic.js)

    • John,

      I did an update to the template on GitHub, could you verify if the problem still occurs.

      Regards,
      Elio

  • now I don’t get any error, but no content as well, the sumary shows that I have 4000+ results but nothing is showen.

    Is it a problem that we are running a danish language pack on a english installation?

    We are running sharepoint enterprise.

    • John,

      It is not about the results, it is because you are not retrieving the properties correctly.

      What is the patch level of your farm?

      It could be that Microsoft has updated their code so that it is not possible anymore unless you do the list / library update explained in this post: Debugging Managed Properties using SharePoint Query Tool v2.

      To be sure if that is the case, I updated the template again with some extra logging. Could you check if you get any logging in the developer tools console of your browser. If no properties are retrieved, you should get the following log message: “Properties array is empty”.

      Regards,
      Elio

  • Got it! I was using the wrong webpart – you have to use ContentBySearchWebPart and NOT the result webpart ;-) Thank you Elio

    • John,

      The template should also work for the search result webpart. Could you also test the updated version for the result web part? Maybe my latest change fixed it.

      Regards,
      Elio

  • John Legaard

    the console is empty – and the result webpart does not work, shows nothing.

  • Pingback: Conditional Color Coding on SharePoint 2013 Task List using JSLink | Keith Tuomi - SharePoint Server MVP()

  • Pingback: Managed properties in Custom display templates giving null | DL-UAT()

  • Rothrock

    I just get “properties array is empty” in the console.

    • NigelPrice

      me too ! it works with OK on one list, but not on two others. Any Ideas what the problem is ?

      • Elio Struyf

        Hi Nigel,

        Are you testing this on-premises? I mentioned that the template may not work in future updates in the last section about: “Office 365 and future on-premises updates”. In the past the libraries were always enabled as a catalog. If you are testing this on a development or test environment, you could try to apply the following list settings via PowerShell:

        Regards,
        Elio

  • Nigel Price

    Hi Elio – Does the ultimate display template work with Office 365 yet ? If so what is the PowerShell command I need to replicate the PowerShell described in the above article ?
    Regards
    Nigel

    • Hi Nigel,

      It should work on O365 as it was initially created on it, but since a long time now, you first need to activate the site catalog functionality of the document library or list.

      On Mikael his blog post I mentioned, he shares the snippet you need for only activating the necessary part:

      The indexedpropertykeys value is a hash of: PublishingCatalogSettings|IsPublishingCatalog