Showing posts with label SharePoint Search. Show all posts
Showing posts with label SharePoint Search. Show all posts

Friday, December 6, 2013

SharePoint 2010 Search - View Properties Link w/ folder and case support - Federated

Issue
  • You have SharePoint 2010 Server Standard or Enterprise
  • SharePoint search results provide a link to the document, but no other links
    • Often times a user has to copy and paste the document library url into the address bar and then search for the document in the library to view the properties or kick off a workflow.  This is extremely inconvenient.
  • You would also like a link to the document's View Item (DispForm.aspx) form
  • You would also like a link to the document's Document Library
  • You would like to configure this at the Search Service level so that the links appear in any search center in the farm utilizing the Search Service and also on the OSSSearchResults pages
  • Utilizing code from the following blogs

Solution
  • Configure the Search Service in Central Administration as follows
  • IMPORTANT
    • Xslt variables and parameters are case sensitive
    • Make sure instructions are followed exactly as written
  • Create 2 managed properties (Metadata Properties in Search Service Application) after your sites have been crawled
    • basic4
      • map to basic:4(text)

        • You have to page to the right after selecting the "basic" group.  It does not show up on the first screen when searching for the crawled properties.  You cannot use the free-text search filter to find this item.
    • listitemid
      • map to ows_ID(integer)
    • Configure Federated Locations in Search Service Application.
      • Click "Local Search Results"
      • Expand "Display Information"
      • Modify the following "Core Search Results Display Metadata" sections
        • Uncheck "Use Default Formatting"
        • Add the following columns to the "Properties" window

          <Column Name="ServerRedirectedURL"/>

          <Column Name="listitemid"/>
          <Column Name="basic4"/>
           
      • Copy the contents of the XSL into a text editor like Visual Studio or Notepad  
        • Find the IsDesignMode parameter and modify as follows

          <xsl:param name="IsDesignMode">True</xsl:param>

          <xsl:param name="listitemid" />
          <xsl:param name="basic4" />
           
      • Find the DisplaySize template call and modify as follows

        <xsl:call-template name="DisplaySize">
        <xsl:with-param name="size" select="size" />
        </xsl:call-template>


        <xsl:call-template name="DisplayViewPropertiesLink">
        <xsl:with-param name="basicFour" select="basic4" />
        <xsl:with-param name="itemUrl" select="url" />
        <xsl:with-param name="siteUrl" select="sitename" />
        <xsl:with-param name="listItemId" select="listitemid" />
        <xsl:with-param name="contentclass" select="contentclass" />
        </xsl:call-template>

        <img style="display:none;" alt="" src="/_layouts/images/blank.gif"/>

      • Find the end of Stylesheet tag at bottom of document and modify as follows

        <!-- A custom template to display a link to view the properties for a document -->
        <xsl:template name="DisplayViewPropertiesLink">
        <xsl:param name="basicFour" /> <xsl:param name="itemUrl" /> <xsl:param name="siteUrl" /> <xsl:param name="listItemId" /> <xsl:param name="contentclass" /> <!-- Variables to convert siteUrl to lower -->
        <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
        <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
        <xsl:if test="$contentclass='STS_ListItem_DocumentLibrary'">
        <xsl:choose>
        <xsl:when test="contains($basicFour,'http')">
        <xsl:variable name="library" select="substring-before(concat(substring-after(translate($siteUrl, $uppercase, $smallcase), concat(translate($basicFour, $uppercase, $smallcase), '/')), '/'), '/')" />
        <xsl:variable name="viewPropUrl" select="concat($basicFour, '/', $library, '/Forms/DispForm.aspx?id=', $listItemId)" />
        - <a href="{$viewPropUrl}">View Properties</a>
        </xsl:when>
        <xsl:otherwise>
        <xsl:variable name="docLibLoc" select="substring-before(substring-after($itemUrl, concat($siteUrl, '/')), '/')" />
        <xsl:variable name="viewPropUrl" select="concat($siteUrl, '/', $docLibLoc, '/Forms/DispForm.aspx?id=', $listItemId)" />
        - <a href="{$viewPropUrl}">View Properties</a>
        </xsl:otherwise>
        </xsl:choose>
        </xsl:if>
        - <a href="{$siteUrl}">
        View Library
        </a>
        </xsl:template>

        <!-- End of Stylesheet -->
        </xsl:stylesheet>

         
      • Copy the contents of the text file into the "Properties:" textbox, replacing all existing text
      • Hit OK to save the changes
    • You may need to reset the index and run a full crawl to get everything working afterwards
      • Sometimes the Search Centers cache the old XSLT for awhile, so the index reset and possibly an app pool recycle may get it to refresh from the federated location.  Or toggling the Core Results web part on the search center page can work as well.


    Monday, July 2, 2012

    AAM Default Zone Configuration Issues

    Scenario
    • You have configured Alternate Access Mappings (AAMs) for a SharePoint web application
    • You may be using ISA or UAG to terminate a FQDN and redirect to an internal URL
    Issue
    • SharePoint Designer Workflow email alerts with document or item links may display the internal URL or other URL from the AAMs, rather than the public URL
    • Search results will not display any results (no results) on the search page when searching using a site scope
      • Ex: From a subsite, you enter a search criteria which is scoped to "This site" and receive no results even though the content has been indexed.  "All Sites" scope works correctly regardless
    Resolution