How to Show the Fax Number in People Search Results in SharePoint 2010

I was recently working with a client who needed to show employees’ fax numbers in their People Search results in SharePoint 2010. Several months ago I got this working for them in SharePoint 2007, but it had to be configured all over again after the upgrade to SharePoint 2010. It was also more involved to set up in SharePoint 2010. I didn’t see where anyone else had documented how to show other fields in People Search results, so I thought I would share how I did this here.

Add Fax Numbers to User Profiles

Before you can expose any information, there must be information to expose. So edit your own profile (or a test user’s profile) to ensure it contains the information you want to see. In the screenshot here, you’ll notice that Connie Watson has edited her profile to contain her Fax number.
Screenshot of User Profile showing Fax number

Configure the Fax Field to be Indexed

It’s possible that the field you want to add is already being indexed, but you’ll probably need to tell SharePoint to index the new field. Log into Central Administration. Click on Application Management > Manage Service Applications > User Profile Service Application. On the Manage Profile Service page, click on Manage User Properties.
Link to Manage User Profiles

In the list of Profile Properties, scroll down to find the field you want to add. You’ll find the Fax number field in the Contact Information section. Hover your mouse over it and select Edit from the drop-down menu.

Edit Fax Number Profile Property Properties

On the Edit User Profile Property page, make a note of the actual name of the field and the data type in the Property Settings section. You’ll need to remember this for later steps. Here you’ll notice that the Fax number field has a Name of “Fax” and the Type is “string (Single Value)”.
Property Settings. Notice Name and Type.

Scroll down to the Search Settings section. Check the box beside Indexed. If this isn’t checked, the field won’t be crawled and it won’t be available to the People Search Results web part. When you are done, scroll to the bottom and click the OK button.
Profile Property Search Settings: Indexed Checked

Add the Fax Fields to the Metadata Properties to be Searched

Although you’ve told the User Profile Service that this field is to be indexed, you still have to tell the Search Service to index it.

In Central Administration click on Application Management > Manage Service Applications > Search Service Application. On the Search Administration page, look in the left-hand navigation, scroll down to the Queries and Results section, and click on Metadata Properties.

In the Search Service Application, Click on Metadata Properties

Scroll through the pages of properties and look carefully to make sure that the field you want to add isn’t already listed. The Fax field isn’t listed by default. On the Metadata Property Mappings page, click on New Managed Property.
Add a New Managed Property

On the New Managed Property page, enter a name for the field. I named it “Fax” to be consistent. Enter a description if you want and select the appropriate data type. I selected Text since the Fax number data type I made note of on the Property Settings page “string (single value)”. Because the data type was a “single value” I left the box unchecked her for “Has Multiple Values.”
New Managed Property settings: Property Name and type

In the Mappings to Crawled Properties section, click on the Add Mapping button.
Add Mapping to Managed Metadata Property

In the Crawled Property Selection dialog, type “Fax” for the Crawled property name and click the Find button. You’ll notice there are three properties that are shown. I added all three of them. You’ll have to add them one at a time though. So, select one of them, then click OK, then click the Add Mapping button again and repeat the process until you’ve added all three of them.
Adding the Crawled Properties

You should see all three Fax properties listed. Scroll to the bottom of the page and click the OK button.
The properties to be crawled have been added

Start a Full Search Crawl

Navigate back to the page where you manage the Search Service Application. In the left hand navigation, in the Crawling section, click Content Sources. Hover your mouse over the content source that contains the User Profile information (it’s probably named “Local SharePoint sites,” and select Start Full Crawl.
Start a full crawl

Add the Fax Column to the People Search Core Results Web Part

Navigate to the Search Center site and perform a People Search. When you see the people search results page (peopleresults.aspx), click on Site Actions –> Edit Page. Locate the People Search Core Results web part and click Edit Web Part.

Edit the People Search Core Results Web Part

In the Tool Pane, expand the Display Properties section and uncheck the box to Use Location Visualization. This will enable the Fetched Properties field, XSL Editor button, and Parameters Editor buttons (these options will be greyed-out and therefore unavailable until you uncheck this box).

Uncheck the Use Location Visualaztion box to enable Fetched Properties , XSL Editor, and Paramenters Editor

Click in the Fetched Properties text box, press CTRL-A on your keyboard, then press CTRL-C to copy all the text to your clipboard. Open Notepad (or your favorite text editor) and paste in the text you copied. Locate the information for the WorkEmail, copy this section.

<Columns>  <Column Name="WorkId"/>  <Column Name="UserProfile_GUID"/>  <Column Name="AccountName"/>  <Column Name="PreferredName" HitHighLight="true"/>  <Column Name="YomiDisplayName" HitHighLight="true"/>  <Column Name="JobTitle" HitHighLight="true"/>  <Column Name="Department" HitHighLight="true"/>  <Column Name="WorkPhone" HitHighLight="true"/>  <Column Name="OfficeNumber" HitHighLight="true"/>  <Column Name="PictureURL"/>  <Column Name="HierarchyUrl"/>  <Column Name="WorkEmail" HitHighLight="true"/>  <Column Name="Path"/>  <Column Name="HitHighlightedSummary"/>  <Column Name="HitHighlightedProperties"/>  <Column Name="Responsibility" HitHighLight="true"/>  <Column Name="Skills" HitHighLight="true"/>  <Column Name="SipAddress" HitHighLight="true"/>  <Column Name="Schools" HitHighLight="true"/>  <Column Name="PastProjects" HitHighLight="true"/>  <Column Name="Interests" HitHighLight="true"/>   <Column Name="OrgNames" HitHighLight="true"/>  <Column Name="OrgUrls"/>  <Column Name="OrgParentNames" HitHighLight="true"/>  <Column Name="OrgParentUrls"/>  <Column Name="Memberships" HitHighLight="true"/>  <Column Name="AboutMe" HitHighLight="true"/>  <Column Name="BaseOfficeLocation" HitHighLight="true"/>  <Column Name="ServiceApplicationID"/>  <Column Name="SocialDistance"/></Columns>

Paste this section back right after the place where you copied it. After you’ve pasted in that section, change WorkEmail in what you pasted to Fax (or the name of the field you want to add). It is very important that everything stays on one line so be careful not to insert any line breaks when you do this. Editing Fetched Properties

After you’ve changed the name of the field you want to add, copy all the text again and paste it back into the Fetched Properties field of the People Search Core Results web part. After you click in the Fetched Properties field, be sure to do a CTRL-A to select all the text that is there before you past in your text or else you will have invalid markup in the box. Scroll to the bottom of the Tool Pan and click the Apply button.

Caution: After editing the Fetched Properties field, you may see an error that says “Property doesn’t exist or is used in a manner inconsistent with schema settings.”

Error in People Search Core Results Web Part: Property doesn't exist or is used in a manner inconsistent with schema settings. If you see this error, it’s probably because you skipped at least one of the previous steps to add the information you want to see to the profile of at least one user, set the column to be indexed, added the column as a searched Metadata Property, and performed a full search crawl after doing all three of those. It is also possible that the full search crawl has not yet finished. Go back and check that the work you did there was saved properly and that the full crawl has finished. If all these have been done the error should go away.

Edit the XSLT to display the Fax Number

Whew! You’re in the home stretch now! Just one more thing to do… actually show the fax number to the users. You should still have the Tool Pane open to edit the properties of the People Search Core Results web part. In the Display Properties section, click on the XSL Editor button.
Click on XSL Editor

You’ll need to make a few changes to the XSL code. I find it easier to copy all the XSL code from the browser dialog Text Editor and paste it into Notepad or some other editor. I also think it’s a good idea to copy the existing XSL code to another text file and save it so you’ll have a backup you can quickly paste back in here to restore it to the default in case you really mess something up—not that you would ever do that, of course.

Because I want the Fax number to appear below the user’s office number, I used the Find feature of Notepad to find the sections that referenced “workphone” and then duplicated those references and changed workphone to fax as needed.

About a third of the way down, you’ll see a section of variables that begin with “has”. This is used by the XSL to indicate if a property exists or not (a particular profile has a work phone or has a fax,.. get it?). Copy the line for the haswph variable and paste the copy on the next line. Edit the line in two places to change the workphone (wph) field to fax.
Adding the hasfax variable in the XSL

About half way down, you’ll see a section with several xsl:if statements that test for the $has variables. One of those is for the “workphone” field. Copy these four lines and paste a copy of them below where you copied them from. Change the references to “wph” and “workphone” to reference “fax” instead.
Adding lines to the XSL to display the Fax number

When you’re done, paste all the XSL code back into the browser dialog text editor and click the Save button. In the Tool Pane, click the OK button to save the changes to the web part and close the tool pane. On the Page ribbon, click the Save & Close button to save the changes to the page.

Perform a people search for a person who has a fax number and notice that the fax number now appears in the results. You did it!
Search results showing both work number and fax number

Add Labels Beside the Properties

Although the Fax number is now showing up, it’s not very obvious that one number is a fax number and the other is a phone number. It would help if there were labels to indicate which number is which. This is easy to add though.

Once again, click on Site Actions –> Edit Page. Locate the People Search Core Results web part and click on Edit Web Part. In the Display Properties section of the Tool pane, click on the XSL Editor button.

Locate the xsl:if sections that display the Work Phone and Fax numbers. After the ‘li’ element and before the ‘xsl:apply-templates’ element, add the markup you want to use for a label. I used <strong>Fax: </strong> as shown in the screenshot here.
Modifying XSL to show labels for Phone and Fax

When you’re done, paste all the XSL code back into the browser dialog text editor and click the Save button. In the Tool Pane, click the OK button to save the changes to the web part and close the tool pane. On the Page ribbon, click the Save & Close button to save the changes to the page.

Perform a people search for a person who has a fax number and notice that labels now appear before both the Phone number and the Fax number.
Search results showing both work number and fax number with labels

Now go take a break and celebrate! You’ve earned it!

3 Comments

  1. Avatar of Mohamed

    Mohamed - January 16, 2012, 2:32 am

    Hello,

    I followed the all above steps. but i couldnt get the result in people search result. please advice.

  2. Avatar of Andy Punton

    Andy Punton - April 11, 2012, 9:32 am

    Great post, wanted to get first name and lastname in a staff directory and this helped me do that.

    The OOTB sort is quite restrictive in a people search query, would it be possible to let me know how you ‘sort’ on any additional fields or particular fields in the xsl file?

Leave a Reply