30 Mai 2008

Display Profile Properties in Table Style

I would like to show you, how you can display profile properties in a table. For example this would allow you to generate a telephone directory from your profile data.

Briefly this would be done in two steps: indexing your profile properties and displaying them with a People Results Web Part.

Let's start creating a managed property. Every property you would like to display on the list, must be crawled by the index and mapped to a managed property.

Creating a managed property
  1. On the SSP admin site, go to the "User profile and property" page, select "View Profile Properties" and select the profile property, you want to display. You could also create new properties.
  2. Make sure that the checkbox "Indexed" is selected.
  3. Repeat this set for every property.
  4. Do a full crawl of the SSP/MySite content source (usually the "Local Office SharePoint Server sites")... and wait until it is completed.
  5. Now you can create managed properties. For this, go to "Search Settings" and choose "Metadata property mappings".
  6. First check, if your desired property is no all ready managed. If not, create a new managed property and add a mapping to the crawled property.
  7. Again start a full crawl.

Sample with the managed property "Xing" which is mapped to the crawled propery "Xing".

Bringing the properties to the screen

Of course you could write a Web Part which iterates over the profiles and then render the data in a gridview. But you can also do this by configuration with the People Search Core Results Web Part.
  1. To begin, you have to create a new Web Part Page and add the "People Search Core Result s".
  2. In the Web Part Properties you set a "Fixed Keyword Query" and select a Cross-Web Part Query ID different from "user query". As "Fixed Keyword Query" you could enter contentclass:"SPSPeople" to display all profiles. But you can also define a custom query, which matches only to a parts of the profiles in your Shared Service Provider.

  3. Under "Selected Columns" add a line for every Managed Property. Check first, if it's not allready there. In our sample, I added <column name="Skills"> before the closing </columns> tag.
  4. Now we have to edit the XSL. If you are a native XSL speaker like my fellow worker Dänu, you can start creating your XSL and can stop reading here.

  5. If not, here some tricks how this could be done. I would suggest, that you copy the existing XSL. This XSL could be used later as a starting point.
  6. With the following XSL you can output the XML code of the search resutls.

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="@* | node()">
    <xsl:apply-templates select="@*|node()" />

    Copy & Paste it in to the XSL editor field and hit "Apply".
  7. Now you have to look at the HTML source code. Search for and copy the hole tag (until the closing ) to the clipboard. In this XML you will see all the properties returned by SharePoint.
  8. If you are familiar with Visual Studio 2008 you could use it to generate a new XSL. Save the XML output to a file und try to run the XSL against that file (Menu: XML \ Show XSLT Output).

Here is a sample XSL which display the name, the e-mail and a like to a Xing profile.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<!-- XSL transformation starts here -->
<xsl:template match="/">
<xsl:apply-templates />

<!-- This template is called for each result -->
<xsl:template match="All_Results/Result">
<xsl:variable name="id" select="id"/>
<xsl:variable name="url" select="url"/>
<a href="{$url}" id="{concat('CSR_',$id)}">
<xsl:value-of select="preferredname"/>
<xsl:value-of select="workemail"/>
<xsl:if test='string-length(xing) &gt; 0'>
<a href="{xing}" id="{concat('XING_',$id)}">
<xsl:value-of select="xing"/>