Sue Hernandez's SharePoint Blog

SharePoint and Related Stuff

Full Text Search – search.asmx – User Profile Title field??

Continuing with my Google Maps V3 dashboard using JQuery and AJAX, and a little bit of CorasWorks Data Integration Toolset (DIT).  My next challenge was that when you click on a location in the InfoWindow, it brings up a pane to the left of the map with details in it.

Well, in those details, I wanted to show all of the people that were related to that Location by a custom profile property in their SharePoint User Profile – i.e. all the employees of that location.

So I chose to use the search.asmx web service to perform a full text query on the People scope.  I searched around on Google and I found the following example:

function initializeUserProfileInfo(location)
	var userSearchQueryString =
              '<QueryPacket xmlns="urn:Microsoft.Search.Query">
                               <QueryText type="MSSQLFT" language="en-us">
                                      select preferredname, firstname, lastname, workemail, workphone,
                                      title, department, pictureurl, description from scope() where
                                      "scope" = \'People\' order by preferredname

         // VERY IMPORTANT - make sure the string above is actually escaped

         var soapRequest = '<?xml version="1.0" encoding="utf-8"?>
                   <soap:Envelope xmlns:xsi=""
                                     <queryXml>' + userSearchQueryString + '</queryXml>

		url: siteURL + "/_vti_bin/search.asmx",
		type: "POST",
		dataType: "xml",
		data: soapRequest,
		contentType: "text/xml; charset=\"utf-8\"",
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			ajaxError(XMLHttpRequest, textStatus, errorThrown);
		success: function(xml) { processAjaxResultUserSearch(xml); }

My problem was was that with the processAjaxResultUserSearch(xml) function, I wanted to get the person’s Title and group by that.  So I happily asked for the TITLE field (they come back as all caps for some reason), but I kept getting the preferred name!  I couldn’t figure out how to get the title from the title field.  I checked in the User Profile store, and yes, the Title field was getting populated correctly.

Well it turns out that if you go to your SSP –> Search Settings –> Metadata Property Mappings, there is a list here of a bunch of mappings such that when you search for the value on the left, you get the value on the right.  Well sure enough, next to Title, it was mapped to (among other things) People:PreferredName(Text).

So I searched around in the mappings, and I found that “JobTitle” was mapped to People:Title(Text).  I used this one, and lo and behold that’s the right one. 

IMPORTANT:  Also, make sure your Query Packet is ESCAPED, so for example

userSearchQueryString =
          '&lt;QueryPacket xmlns="urn:Microsoft.Search.Query"&gt;

... etc etc

Just thought I’d pass that along.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: