Showing posts with label User Profiles. Show all posts
Showing posts with label User Profiles. Show all posts

Wednesday, June 16, 2010

People Results' "Refine Your Search" - "Show more options" not working

I noticed the other day after creating the custom People Results page that the button of "Show more options" was not working and when I clicked it, a yellow exclamation of a Java error showed up at the bottom-left of the IE window. After a lot of headache I was able to figure out the problem.

In my quest for the perfect (for our company) people results page I removed the "People Search Box" that was in there by default at the top, in favor of a custom icon and link back to perform another Advanced People Search. Well that was the problem. Apparently for the "Show more results" link to actually work you need to have that search box there.

I added the People Search Box back in and marked it as hidden and everything started working again

Custom People Results

I did not like the results format of a People search so I decided to create my own. On the results page I edited the page, edited the XSL and made this:


To do this, you need to know the values for each column of data. Here is mine, yours may be different but the formatting would be the same:

 <xsl:stylesheet version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="FileName" />
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/">
<xsl:call-template name="dvt_1"/>
</xsl:template>
<xsl:template name="dvt_1">
<xsl:variable name="dvt_StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/All_Results/Result"/>
<table border="1" width="100%" cellpadding="4" cellspacing="0">
<tr valign="top">
<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
<th class="ms-vh" width="1%" nowrap="nowrap"></th>
</xsl:if>
<th class="ms-vh" nowrap="nowrap">Name</th>
<th class="ms-vh" nowrap="nowrap">Nickname</th>
<th class="ms-vh" nowrap="nowrap">Title</th>
<th class="ms-vh" nowrap="nowrap">Company</th>
<th class="ms-vh" nowrap="nowrap">Office</th>
<th class="ms-vh" nowrap="nowrap">Phone</th>
<th class="ms-vh" nowrap="nowrap">Extension</th>
<th class="ms-vh" nowrap="nowrap">E-Mail</th>
</tr>
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows"/>
</xsl:call-template>
</table>
</xsl:template>
<xsl:template name="dvt_1.body">
<xsl:param name="Rows"/>
<xsl:for-each select="$Rows">
<xsl:call-template name="dvt_1.rowview"/>
</xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.rowview">
<tr>
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="class">ms-alternating</xsl:attribute>
</xsl:if>
<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
<td class="ms-vb" width="1%" nowrap="nowrap">
<span ddwrt:amkeyfield="" ddwrt:amkeyvalue="string($XPath)" ddwrt:ammode="view"></span>
</td>
</xsl:if>
<td class="ms-vb">
<a href="https://mysite.yourdomain.com/Person.aspx?guid={userprofile_guid}">
<xsl:value-of select="preferredname"/>
</a>
</td>
<td class="ms-vb">
<xsl:value-of select="nickname"/>
<script type="text/javascript">
document.write("&amp;nbsp;");
</script>
</td>
<td class="ms-vb">
<xsl:value-of select="jobtitle"/>
<script type="text/javascript">
document.write("&amp;nbsp;");
</script>
</td>
<td class="ms-vb">
<xsl:value-of select="company1"/>
<script type="text/javascript">
document.write("&amp;nbsp;");
</script>
</td>
<td class="ms-vb">
<xsl:value-of select="officenumber"/>
<script type="text/javascript">
document.write("&amp;nbsp;");
</script>
</td>
<td class="ms-vb">
<xsl:value-of select="workphone"/>
<script type="text/javascript">
document.write("&amp;nbsp;");
</script>
</td>
<td class="ms-vb">
<xsl:value-of select="extension1"/>
<script type="text/javascript">
document.write("&amp;nbsp;");
</script>
</td>
<td class="ms-vb">
<a href="mailto:{workemail}">
<xsl:value-of select="workemail"/>
<script type="text/javascript">
document.write("&amp;nbsp;");
</script>
</a>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>

Possible Error
I did initially run into the problem whereas I was getting this error when trying to display the results of a people search:

 System.NullReferenceException:   
Object reference not set to an instance of an object. at
System.Xml.XmlNode.RemoveChild(XmlNode oldChild) at
Microsoft.Office.Server.Search.WebControls.PeopleCoreResultsWebPart.DeleteElementAddToMyColleaguesURL(XmlNode result) at
Microsoft.Office.Server.Search.WebControls.PeopleCoreResultsWebPart.CreateXmlDocument() at
Microsoft.Office.Server.Search.WebControls.PeopleCoreResultsWebPart.SortBySocialDistance() at
Microsoft.Office.Server.Search.WebControls.PeopleCoreResultsWebPart.GetXPathNavigator(String viewPath)

Turns out that the results Web Part needed it's "Default Results View" to be set to "Relevance" instead of "Social Distance" as it had been by default. After that change the error went away.

Custom People Search Page

Within MOSS we are given 2 options for searching for people: The basic search box and the "options" drop-down, if so enabled. I didn't like any of these so I decided to make my own.

Within Search Center I created an Advanced Search page, removed all of it's components and added a Content Editor Web Part (CEWP) to create this:



Here is my code:

 <head>  
<META name="WebPartPageExpansion" content="full">
<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:PublishingContactPicture msdt:dt="string">, </mso:PublishingContactPicture></mso:CustomDocumentProperties></xml><![endif]-->
<style type="text/css">
.style1 {
margin-right: 52px;
}
.style2 {
text-align: center;
}
.style3 {
background-color: #CCCCCC;
}
.style4 {
color: #FFFFFF;
}
.style5 {
color: #666666;
}
.style6 {
color: #666666;
background-color: #CCCCCC;
}
</style>
</head>
<script language="javascript" type="text/javascript">
$("#searchButton").click(function() {
// find the values in the form
var firstname = $("input#firstname").val();
var lastname = $("input#lastname").val();
var jobtitle = $("input#jobtitle").val();
var department = $("input#department").val();
var division = $("input#division").val();
var company = $("input#company").val();
//build the url
var url = "/searchcenter/Pages/peopleresults.aspx?k="
//build k variable to ensure users put in SOMETHING
var k = "";
if(firstname != "") k = k + " FirstName:" + firstname;
if(lastname != "") k = k + " LastName:" + lastname;
if(jobtitle != "") k = k + " JobTitle:" + "\"" + jobtitle + "\" ";
if(department != "") k = k + " Department:" + "\"" + department + "\" ";
if(division != "") k = k + " Division:" + "\"" + division + "\" ";
if(company != "") k = k + " Company1:" + "\"" + company + "\" ";
k = encodeURIComponent(k);
if(k != "")
{
url = url + k;
window.location = url;
}
else
{
$("#errorMsg").html("<font color=red><Strong>You must enter at least one criteria to search on</Strong></font>");
}
});
});
</script>
<!--Build the table with the inputs-->
<table cellpadding="3" cellspacing="0" border="0" width="450px" ID="Table3" class="style1">
<tr>
<td nowrap class="style3" colspan="5">
<strong><span class="style5">Find people with...</span><br>
</strong><span class="style4"><em>(You may use partial names to search with)</em></span></td>
</tr>
<tr>
<td nowrap style="width: 100px">
First Name:
</td>
<td width="80">
<input size="20" maxlength="100" id="firstname" name="firstname" type="text">
</td>
<td width ="40">&nbsp;</td>
<td nowrap style="width: 100px">
Last Name:
</td>
<td>
<input size="20" maxlength="100" id="lastname" name="lastname" type="text">
</td>
</tr>
<tr>
<td nowrap colspan="5" class="style6">
<strong>Other criteria to search on...<br>
</strong><span class="style4"><em>(Exact names are required)</em></span></td>
</tr>
<tr>
<td nowrap style="width: 100px">
Job Title:
</td>
<td width="80">
<input size="20" maxlength="100" id="jobtitle" name="jobtitle" type="text"></td>
<td width ="40">&nbsp;</td>
<td nowrap style="width: 100px">
Department:
</td>
<td>
<input size="20" maxlength="100" id="department" name="department" type="text"></td>
</tr>
<tr>
<td nowrap style="width: 100px">
Division:</td>
<td width="80">
<input size="20" maxlength="100" id="division" name="division" type="text">
</td>
<td width ="40">&nbsp;</td>
<td nowrap style="width: 100px">
Company:</td>
<td>
<input size="20" maxlength="100" id="company" name="company" type="text">
</td>
</tr>
<tr>
<td nowrap colspan="5" class="style2">
<input type="button" id="searchButton" value="Search">
</td>
</tr>
<tr>
<td nowrap colspan="5">
<div id="errorMsg" class="style2" />
</td>
</tr>
</table>

Remove warning / yellow exclamation on profile pages

For our application we didn't want the warning / yellow exclamation to appear on user Profile Pages. As described on this page, to remove the exclamation you need to,

  1. Log into the front-end server
  2. Navigate to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\
  3. Backup the editprofile.aspx
  4. Edit the editprofile.aspx and do a search for SPSWC:ProfileEditor id="ProfileEditor" id="ProfileEditor" runat="server"
  5. You need to add ShowWarningIcon="False" into that sepcific tag so that it looks like this: SPSWC:ProfileEditor id="ProfileEditor" id="ProfileEditor" ShowWarningIcon="False" runat="server"
  6. Save