SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

MOSS BDC, Search and Web Service: Modifying Search Results Web-Part

INTRODUCTION

This post is related to my other post regarding securing search results for currently-logged-in user in Sharepoint when querying BDC Web Service entity:
http://www.sharepointblogs.com/tommysegoro/archive/2008/09/17/moss-bdc-search-and-web-service-securing-the-search-results-for-particular-user.aspx

I'm now interested in how I can modify the search results web-part to display the actual entity name. OOTB it will give you EntityType.aspx. So if your entity type is called FileEntity the search results web-part will render FileEntity.aspx everywhere! I want to render Filename1.aspx, Filename2.aspx, etc.

OOTB:

 

THE SOLUTION

1. Add a meta-data property mapping in SSP. Let's give it a name: TommyFilename and add mapping to the BDC crawled property. 

2. Edit the Search Core Results Web-Part -> Results Query Options -> Selected Columns. Add your custom managed-property in here.

<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">    <Columns>        <Column Name="TommyFilename"/><Column Name="WorkId"/>        <Column Name="Rank"/>        <Column Name="Title"/>        <Column Name="Author"/>        <Column Name="Size"/>        <Column Name="Path"/>        <Column Name="Description"/>        <Column Name="Write"/>        <Column Name="SiteName"/>        <Column Name="CollapsingStatus"/>        <Column Name="HitHighlightedSummary"/>        <Column Name="HitHighlightedProperties"/>        <Column Name="ContentClass"/>        <Column Name="IsDocument"/>        <Column Name="PictureThumbnailURL"/>    </Columns>    </root>   

3. Edit the Search Core Results Web-Part XSL under Data View Properties. Go to around line 111:

OOTB:
  <span class="srch-Title">
   <a href="{$url}" id="{concat('CSR_',$id)}" title="{$url}">
    <xsl:choose>
     <xsl:when test="hithighlightedproperties/HHTitle[. != '']">
         <xsl:call-template name="HitHighlighting">
          <xsl:with-param name="hh" select="hithighlightedproperties/HHTitle" />
         </xsl:call-template>  
     </xsl:when>
     <xsl:otherwise><xsl:value-of select="title"/></xsl:otherwise>
    </xsl:choose>
   </a>
    <br/>
   </span>

Modify that to:
  <span class="srch-Title">
   <a href="{$url}" id="{concat('CSR_',$id)}" title="{$url}">
    <xsl:choose>
     <xsl:when test="tommyfilename[. != '']">
         <xsl:value-of select="tommyfilename"/>
     </xsl:when>
     <xsl:otherwise><xsl:value-of select="title"/></xsl:otherwise>
    </xsl:choose>
   </a>
    <br/>
   </span>

NOTE: The property name HAS TO BE LOWER CASE! Remember we named it TommyFilename before, didn't we? It won't work if you use TommyFilename but it will work if you use tommyfilename.

That's it! You can then see below:

 

APPENDIX

To check what XML it returns, edit that XSL Data-View Properties again and replace the content with:

<?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="/">
<xsl:copy-of select="*"/>
</xsl:template>
</xsl:stylesheet>

Save the web-part then view HTML Source of the page then you can see something like below:

<All_Results>
  <Result>
    <id>1</id>
    <tommyfilename>charlie_and_the_chocolate_factory_06.jpg</tommyfilename>
    <workid>5</workid>
    <rank>819</rank>
    <title>FileEntity.aspx</title>
    <author></author>
    <size>0</size>

...................

The custom property is actually recognized using ALL lower case naming convention. That is why TommyFilename will not work.

 

Hope this helps,
Tommy


Posted 09-19-2008 5:30 PM by tommysegoro

Comments

Arun wrote re: MOSS BDC, Search and Web Service: Modifying Search Results Web-Part
on 09-30-2008 7:27 AM

Hey Tommy,

Nice blog. You know what,  I was getting confused why the property value was not shown in webpart even after I edited the XSLT, seeing your post helped me to understand that the column name has to be in lower case :S

Thanks a lot ... :)

CRM Software wrote re: MOSS BDC, Search and Web Service: Modifying Search Results Web-Part
on 02-13-2009 5:13 PM

The first step for deploying CRM should be: Get cross department agreement on the

functionality you need most.  Then look for software that is geared for your

needs.  There are many good <a

href="www.smartaboutsales.com/crm-software-packages-all-in-one.html" >CRM

Software programs </a>

available.  It can be difficult to determine which, based on a company’s specific

needs, are the best ones to evaluate.  You can use the <a

href="http://www.smartaboutsales.com"> CRM Software Comparison tool </a> to narrow

down your options to the best short list.  It searches 80 CRM software packages

and gives instant results, listing only those that match your selected features.  

And, its free.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.