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.
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.
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.
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)”.
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.
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.
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.
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.”
In the Mappings to Crawled Properties section, click on the Add Mapping button.
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.
You should see all three Fax properties listed. Scroll to the bottom of the page and click the OK button.
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.
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.
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).
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.
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.
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.”
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.
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.
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.
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!
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.
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.
Now go take a break and celebrate! You’ve earned it!