A common request is to create custom user profile properties to store information about users, this is something I will covered in my previous post. This is helpful when viewing their profile but if this is an important piece of information then it is possible you may need to include this in the search results for the people search and this is what I shall be covering today. In this example my property is called 'TestProperty', see below.
Next I have populated my user profile to contain some test information for this property, see below
Next you have to set up a new 'Managed Property' that relates to our new user profile property. To do this navigate to your shared service provider then select 'Search Settings'. Once in the search settings section click 'Metadata property mappings' this will then give you a list of all the existing properties. To create a new managed property click 'New Managed Property' in the toolbar. Enter the name, description, select the type of information it has to hold, this should match what you selected for the user property. The most important section on this page is the mapping property as this decides what crawled property your managed property is associated with. In this case I am mapping my new managed property to my user profile property, see below.
Once you have set up the new Managed Property you need to perform a full crawl to make sure the test data entered is picked up by the search results. Once the full crawl is finished you can check that the new property has information in it by clicking on 'Managed Properties' and then clicking on your newly created managed property and you should see in the 'Content using this property' section it will have the number of items using this property, see below.
Now we have the property with the data the next step is to adjust the search results to pull out the new property. In this example I will edit the people search core results web part but the same principle applies to any of the search web parts. First navigate to the people search results page and open the people search core results webpart editor. Second, expand the 'Results Query Option' and click in the 'selected columns' textbox. Once you have done this a button with three dots will appear on the right hand side of the textbox if you click on that it will open an editor with a list of all the columns that are available to be used to display information in the webpart, I find it easier to copy the content and paste it into visual studio but similarly you can used notepad or even edit it in the editor. Where ever you choose to edit the columns you need to copy one of the existing columns and replace the name with your own name, for some reason I could only get this to work if the name is
ALL in capitals, see below.
The final step is to edit the XSL that is used to render the generated XML. To do this click on 'XSL Editor' under the 'Data View Properties' section. You can place the information anywhere you want but for this example I shall add it next to the other office profile information. The first step is to add the new property as a parameter to the 'DisplayOfficeProfile' again the name of the property must be capitalised for this to work, see below.
The final step is to change the 'DisplayOfficeProfile' template to include this new parameter and display the information. The screenshot below shows what the new template looks like.
If you now save the editor, save and close the web then publish the page if you perform another search you should see the information appear in the webpart. One thing i have noticed is sometimes when you make a change to the webpart and click 'OK' it will look like the webpart is throwing an error. I'm not sure why this is but if you publish the page and perform another search it works ok.
Hope this help.