Tag Archives: Office Web App

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.

 

Advertisements