Open SharePoint 2013 Search Results In The Client Application

If you configure SharePoint 2013 to work with Office Web Apps (link), by default SharePoint will open Word, Excel etc. documents in the browser using the Office Web Apps.  You can configure SharePoint to open documents in the client application or browser on a site collection or document library basis, see here.  However, even if you choose to configure SharePoint to open documents in the client application at the site collection, search results still open in the browser.  In my case I wanted Office Web App integration to enable search result previews, but I wanted search results to open in the client application.

In order to open search results in the client application I had to alter the Item_CommonItem_Body.html search results display template.  Item_CommonItem_Body.html is the display template that’s rendered  by _#=ctx.RenderBody(ctx)=#_ within a display template.  Below is the section in one of my custom display templates.

Search2013WebApps1For an overview of display templates read this MS Technet blog article.

Within Item_CommonItem_Body.html is a section that references ctx.ScriptApplicationManager.states.openDocumentsInClient.

Search2013WebApps2

In order to force search results to open in the client application I added a line in my custom display template to set the value of ctx.ScriptApplicationManager.states.openDocumentsInClient to true.

Search2013WebApps3

Open in Client Detail

This results in the behavior where search result previews using Office Web Apps still work, but when a user clicks on a result it opens in the client application.

 

Advertisement

7 thoughts on “Open SharePoint 2013 Search Results In The Client Application

  1. dominik

    Hi,
    thank you for the solution.
    At the Moment I have the problem that the first search result in the list still have the deaultOpenItem=1 extension and it open in the browser. The other results in the list works fine.
    Do you have an idea why?

    regards
    Dominik

    Reply
  2. shappy

    I had this issue too but I was able to fix it by moving the suggested line of code to be the first line in the script tag.

    Reply
  3. sahu

    at the bottom of the page. there is one setting as preference .. you can change that behavior of opening document.

    Reply

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 )

Facebook photo

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

Connecting to %s