PhenomeCloud Insights

SharePoint 2013 Customize Send button in Search Callout

Written by PEC | Aug 6, 2015 7:35:00 AM

Customizing the Send Action in the callout/popup on hovering over the search items within the default search page in a site collection can be quirky for the ones who don’t know the ropes.

The Send Action uses ‘mailto :’ HTML email link.

In this walkthrough you’ll learn how to open outlook email client application with an attachment i.e. a word document of the search item for which we click the S end link in the callout and we will be using SharePoint 2013 designer to achieve it.

To open outlook we’ll rely on javaScript and ActiveX component of the internet browser.

Enabling ActiveX:

Open IE and go to, 

Tools → Internet Options → Security Tab …

Now select a zone based on your site’s hosting i.e. internet or intranet etc.

Now click on Custom Level button → Ensure that "Initialize and script ActiveX controls is not marked safe for scripting " is enabled/prompted - i t’s under ActiveX controls and plug-ins section, click OK to close all the opened windows. Once this is completed, clear the browser cookies and cache. Close all your browser sessions. Reopen the IE to launch your site. We can also use ActiveX in Chrome or Firefox by installing necessary Add-ons such as IE Tab.

Putting the pieces together:

To get off up and running first we need to locate the .html file where the Send hyperlink is declared.

You can find all the search display templates in the following location ~sitecollection/_catalogs/masterpage/Display Templates/Search/ by activating SharePoint Server Publishing Infrastructure in the Site Collection.

To activate go to Site Settings → Site Collection Administration → Site Collection Features and activate SharePoint Server Publishing Infrastructure. 

The Send Action from the search results callout is present in ~sitecollection/_catalogs/masterpage/Display

Templates/Search/Item_CommonHoverPanel_Actions.html , checkout that file in SharePoint 2013 designer and right click it and choose Edit File in Advanced Mode, now find the anchor tag which has clicktype="ActionSend" and we’re going to write an onclick event for it. 

Create a javaScript file in Scripts folder as shown below in the All Files → Scripts → emailmanager.js

Now open the .html file of the corresponding .masterpage of the site by checking it out and editing it in advanced mode, and at the bottom of the body tag add a reference to our javaScript file i.e. emailmanager.js as follows

 

After you’ve added your script file in the .html file check in the change and cross check your .masterpage whether your script tag is also included.

Now checkout the javaScript file which you’ve added and add the following code,

In the above code we’re checking the extension of the file in the URL, if it’s .doc or .docx then we prevent the default action of the DOM element and we open outlook by using ActiveXObject, notice that we’re passing URL of the word document in the attachment and not attaching a physical file for more info refer to

Go back to the Item_CommonHoverPanel_Actions.html which we checked out earlier and call the methodprocessActionSend in the onclick event for that anchor tag and pass the necessary parameters as a string.


We’re using parameters from the javaScript code which is written in this <!--#_ ... _#--> annotation, now check in the file.

Start doing a search within the site collection for which we’ve customized the Send Action, for anything else other than word document it will open outlook with a hyperlink to the content in the body, and for word document’s you would get them as an attachment in the e-mail.

If we choose prompt instead of enable for ActiveX which is more secure then we get this prompt, when we click yes, outlook opens with the word document attached.

Voila! You’ve your own custom action for word documents in the search results callout.

Phenomecloud is an enthusiastic family of individuals, fervent to make lives simpler through effective use of technology. Our mission is to implement solutions that drives business results. Know more insights from our thoughts and experience.

Contact us today or call 1-855-978-6816 to talk with us about your business needs.