Three Useful Managed Properties for Working with Office Web Apps

Elio Struyf

by Elio Struyf on 3/23/2015

Share this:
Print

Article Details

Date Revised:
3/23/2015

Applies to:
OWA, ServerRedirectedEmbedURL, ServerRedirectedPreviewURL, ServerRedirectedURL, SharePoint Search Center


Using OWA in SharePoint Search Center

When working in Office 365 / SharePoint on-premises, you probably already use Office Web Apps (OWA) to create or modify your documents. The power of OWA is also leveraged inside a SharePoint Search Center to show the content of a document inside the hover panel.

OWA lets you see detailed information about a file you might want to open

Document preview

This kind of functionality is very helpful for finding the document you are searching for. You can also leverage the OWA functionality inside your own display templates by making use of the following managed properties:

  • ServerRedirectedURL
  • ServerRedirectedPreviewURL
  • ServerRedirectedEmbedURL

Each property has its own purpose. In the next sections I will explain them one by one.

ServerRedirectedURL managed property

The ServerRedirectedURL managed property provides you a link that opens the document in OWA. You can use this managed property if you want your users to open documents in OWA instead of their client applications.

Sample managed property value: https://tenant.sharepoint.com/sites/Operations/_layouts/WopiFrame.aspx?sourcedoc={9AF85718-3C5A-4FEC-9777-BBE609E610EC}&file=New%20Training%20Programs.pptx&action=default&DefaultItemOpen=1

Usage: You can use this managed property value inside an anchor tag.

<!--#_
var serverRedirectedURL = $getItemValue(ctx, 'ServerRedirectedURL');
_#-->

<a href="_#= serverRedirectedURL =#_" title="ServerRedirectedURL">Link to the document in OWA</a>

Use ServerRedirectedURL to open a document in OWA instead of a client application

Link to the document in OWA

ServerRedirectedPreviewURL managed property

You can use the ServerRedirectedPreviewURL managed property to add a preview image next to the content of the document like in your SharePoint Search Center.

Use ServerRedirectedURL to create a preview image for a result in Search Center

Search result with preview image

Sample managed property value: https://tenant.sharepoint.com/sites/Operations/_layouts/WopiFrame.aspx?sourcedoc={9af85718-3c5a-4fec-9777-bbe609e610ec}&action=imagepreview

Usage: You can use this managed property value as the source attribute of an image tag.

<!--#_
var serverRedirectedPreviewURL = $getItemValue(ctx, 'ServerRedirectedPreviewURL');
_#-->

<img src="_#= serverRedirectedPreviewURL =#_" alt="ServerRedirectedPreviewURL" />

Use ServerRedirectedURL as the source attribute of an image tag

Preview image example

ServerRedirectedEmbedURL managed property

Use the ServerRedirectedEmbedURL managed property to render the WOPI frame inside the hover panels.

Sample managed property value: https://tenant.sharepoint.com/sites/Operations/_layouts/WopiFrame.aspx?sourcedoc={9af85718-3c5a-4fec-9777-bbe609e610ec}&action=interactivepreview

Usage: You can use this managed property value as the source attribute inside an iFrame.

<!--#_
var serverRedirectedEmbedURL = $getItemValue(ctx, 'ServerRedirectedEmbedURL');
if(!Srch.U.n(serverRedirectedEmbedURL)) {
_#-->

<div class="ms-srch-hover-viewerContainer" style="height:345px;200px">
<iframe src="_#= serverRedirectedEmbedURL =#_" scrolling="no" frameborder="0px" style="height:100%;width:100%"></iframe>
</div>

<!--#_
}
_#-->

Use ServerRedirectedEmbedURL as the source attribute for an iFrame

Document preview

Adding these properties in your template

You need to add these managed properties to the ManagedPropertyMapping attribute inside the display template before you can start using them in your display templates.

<mso:ManagedPropertyMapping msdt:dt="string">'Link URL'{Link URL}:'Path','Line 1'{Line 1}:'Title','Line 2'{Line 2}:'','FileExtension','SecondaryFileExtension','ServerRedirectedEmbedURL','ServerRedirectedPreviewURL','ServerRedirectedURL'</mso:ManagedPropertyMapping>

On my GitHub repository you can find a sample display template with these properties: item display template with OWA properties.

Related posts


Topic: Development

Sign in with

Or register