Jeremy Stein - Brain

« »

InfoPath forms in SharePoint search results

When InfoPath forms were returned in our SharePoint 2010 search results, the links pointed directly to the form XML. When user clicked on the links, it would attempt to download the forms to open them locally. We want the forms to open online.

I read that this can be fixed by modifying the XSLT in the search webpart to check for contentclass=’STS_ListItem_XMLForm’. It didn’t work.

Later, I found that I could view the source XML being transformed in that webpart with this XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xmp><xsl:copy-of select="*"/></xmp>

From this, I learned that the source XML already contained an entity “serverredirectedurl” which, as far as I can tell, only has a value for InfoPath forms and contains the appropriate URL to launch to access the form online.

So, I modified the default XSLT and replaced this line:

<xsl:variable name="url" select="url"/>

with this:

<xsl:variable name="url">
  <xsl:when test="serverredirectedurl[. != '']">
    <xsl:value-of select="serverredirectedurl"/>
    <xsl:value-of select="url"/>

November 14, 2012 1 Comment.

One Comment

  1. Tim replied:

    Hi Jeremy,

    Thanks for this tip! This was exactly what I needed to know.

    You might want to put a link to this site to help people see how to set up search web parts in general. I didn’t really understand this post until I found that.

    Also, I wasn’t able to edit the XSLT until I actually ran a search, and THEN edited the web part on the page, with the search results showing. Without a search box, or an active search, the XSL Editor is always empty, hence nothing to edit.

    Thanks again!

    November 14th, 2014 at 1:22 pm. Permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Why ask?

« »