{"id":196,"date":"2012-11-14T14:21:54","date_gmt":"2012-11-14T19:21:54","guid":{"rendered":"https:\/\/jeremystein.com\/brain\/?p=196"},"modified":"2012-11-14T14:25:27","modified_gmt":"2012-11-14T19:25:27","slug":"infopath-forms-in-sharepoint-search-results","status":"publish","type":"post","link":"https:\/\/jeremystein.com\/brain\/infopath-forms-in-sharepoint-search-results\/","title":{"rendered":"InfoPath forms in SharePoint search results"},"content":{"rendered":"<p>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.<\/p>\n<p>I <a href=\"http:\/\/montymyers.blogspot.com\/2009\/10\/force-browser-enabled-forms-to-open-in.html\">read<\/a> that this can be fixed by modifying the XSLT in the search webpart to check for contentclass=&#8217;STS_ListItem_XMLForm&#8217;.  It didn&#8217;t work.<\/p>\n<p>Later, I <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms546985%28v=office.14%29.aspx\">found<\/a> that I could view the source XML being transformed in that webpart with this XSLT:<\/p>\n<pre>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http:\/\/www.w3.org\/1999\/XSL\/Transform\"&gt;\r\n&lt;xsl:output method=\"xml\" version=\"1.0\" encoding=\"UTF-8\" indent=\"yes\"\/&gt;\r\n&lt;xsl:template match=\"\/\"&gt;\r\n&lt;xmp&gt;&lt;xsl:copy-of select=\"*\"\/&gt;&lt;\/xmp&gt;\r\n&lt;\/xsl:template&gt;\r\n&lt;\/xsl:stylesheet&gt;<\/pre>\n<p>From this, I learned that the source XML already contained an entity &#8220;serverredirectedurl&#8221; 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.<\/p>\n<p>So, I modified the default XSLT and replaced this line:<\/p>\n<pre>&lt;xsl:variable name=\"url\" select=\"url\"\/&gt;<\/pre>\n<p>with this:<\/p>\n<pre>&lt;xsl:variable name=\"url\"&gt;\r\n  &lt;xsl:choose&gt;\r\n  &lt;xsl:when test=\"serverredirectedurl[. != '']\"&gt;\r\n    &lt;xsl:value-of select=\"serverredirectedurl\"\/&gt;\r\n  &lt;\/xsl:when&gt;\r\n  &lt;xsl:otherwise&gt;\r\n    &lt;xsl:value-of select=\"url\"\/&gt;\r\n  &lt;\/xsl:otherwise&gt;\r\n  &lt;\/xsl:choose&gt;\r\n&lt;\/xsl:variable&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-196","post","type-post","status-publish","format-standard","hentry","category-sharepoint"],"_links":{"self":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/comments?post=196"}],"version-history":[{"count":0,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"wp:attachment":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}