Jeremy Stein - Brain
« InfoPath checkbox onchange doesn’t work when deployed to SharePoint | KB2598354: An error occurred while running detection » |
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="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <xmp><xsl:copy-of select="*"/></xmp> </xsl:template> </xsl:stylesheet>
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:choose> <xsl:when test="serverredirectedurl[. != '']"> <xsl:value-of select="serverredirectedurl"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="url"/> </xsl:otherwise> </xsl:choose> </xsl:variable>
One Comment
- 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.
« InfoPath checkbox onchange doesn’t work when deployed to SharePoint | KB2598354: An error occurred while running detection » |
Leave a Reply