SharePoint 2010 allows for the creation of custom user profile properties in much the same way 2007 did. This allows a company to tailor user profiles to fit their unique business needs and better promote social networking in the enterprise.
One issue I recently ran into with this however appeared when I tried to search on these new custom properties. It so happens, that SharePoint does not automatically tie these new properties into the search experience, even if you mark the new property as one to be indexed. I am going to walk through the steps required to create a new user profile property and make it appear in SharePoint 2010’s people search so hopefully someone else doesn’t waste as much time as I did getting this to work.
For this example I am going to create a Property called “Previous Customers” that lists all of the customers a person has worked with in the past. Note that in my case this is a multi-value property, so make your selections accordingly.
Part 1 – Creating a Term Set for the Profile Property (This will store all of the Previous Customers entered by the users in a nice, clean set that is then reusable)
1) Navigate to the Managed Metadata Service Application in Central Admin
2) Create a new group for Profile Property Term Sets
3) Create a new Term Set for the Profile Property you are about to create
Part 2 – Creating the Profile Property
1) Navigate to the User Profile Service Application in Central Admin
2) Click on “Manage User Properties”
3) Click on “New Property”
4) Fill out the information requested in the dialog box, selecting the term set created in Part 1.
5) Make sure you select the Indexed check box
Now if you go to a user profile you should see the new property you just created.
So, at this point you may think (I did) that since you clicked the Indexed box, this will be indexed and make people appear in the People Search Results… Wrong! We still have quite a bit of work to do.
Part 3 – Setting up the Metadata Properties in Search (This is kind of the tricky part)
1) Navigate to your Search Service in Central Admin (Fast Query Service if using FAST Search)
2) Click on Metadata Properties
3) First make sure your Crawled Properties are there – Click on “Crawled Properties” (You may need to do an incremental crawl before they show up.)
4) Do a search for your term (In my Case, PreviousCustomers – Results are shown in the image below)
5) You should have two properties, one beginning with “ows_taxId” and the other starting with “People:” – If not, do an incremental crawl and try again, also make sure you filled out at least one profile with some sample data.
6) We need to create a new Managed Property to map your custom user profile property to, so click back a couple of times and click on “New Managed Property”
7) Fill out the resulting dialog box, mapping it to your Crawled Property – my example is shown below.
8) Now go back to your crawled properties and set their mappings per the image below
a. Select ContentsHidden as a mapping for your People Attribute
b. Do not select Included in Index in either one
Now if you kick off a crawl you should get some results back when you perform a search. What this looks like is shown below.
So, you should notice that while you get a result back (I have “City of” as one of my previous customers) is does not display your custom field in the results. To correct this we need to modify the xslt in the people results web part.
I hate editing xslt, but find it pretty easy if you copy some of what is already there. Past Projects for example is an out of the box profile property that is like mine (Multi-Valued, appears in results, text, etc.) so wherever I saw PastProjects in the xslt, I copied that section with my term PreviousCustomers.
Part 4 – Modify the XSLT in the People Search Results Web Part
The three additions are below… I suggest using Visual Studio or something to edit the xslt other than the browser – much easier.
Add A Parameter (I Didn’t end up using this, but added it anyway)
<xsl:param name=”PreviousCustomersLabel” />
Declare a variable
<xsl:variable name=”haspc” select=”($FilterNodeSet and $FilterNodeSet/@title=’PreviousCustomers’) or hithighlightedproperties/previouscustomers/@hashh > 0″/>
Add an If Statement to display the Property
<xsl:with-param name=”multivalue” select=”hithighlightedproperties/previouscustomers”/>
<xsl:with-param name=”cutoff” select=”5″/>
The end result is what you wanted to begin with, your results being shown and the proper section being highlighted.