This project has moved and is read-only. For the latest updates, please go here.

SPFindPeoplePicker to get more user information

Jun 27, 2013 at 5:22 PM
I am using the SPFindPeoplePicker and it returns the name of the user - Bill Smith - in order for me to continue on to get move info about the person (phone number, title, etc) I need their account name - i.e. "adtree\bill123".

How can I get to this info? currentValue appears to only bring back the displayed name.


<SCRIPT type=text/javascript src="/sites/supprt/sandbx/SCRIPTS/jquery-1.8.3.min.js"></SCRIPT>

<SCRIPT type=text/javascript src="/sites/supprt/sandbx/SCRIPTS/jquery.SPServices-0.7.2.min.js"></SCRIPT>

<SCRIPT type=text/javascript>

var assigned;
var assignedToPeoplePicker;

function PreSaveAction(){

   assigned = $().SPFindPeoplePicker({ peoplePickerDisplayName: "Assigned To"});
   assignedToPeoplePicker = (assigned.currentValue);

   return false;

Jun 27, 2013 at 5:32 PM

Every setup is different. In some cases, you'll get the user's name and in others the account. The object I return has all of the information which is available in the People Picker. You may need to call other Web Service operations to get additional information about the user.

Jun 27, 2013 at 5:35 PM
Yep - in 2007 I used a People Scope search to drag in more info; most of the SPServices stuff either user current user, or require you to pass in account name - if I could find a way to make the leap from that People Picker displayed name return to the account name, I would be golden!


Jun 27, 2013 at 5:38 PM
Unfortunately, I can't give you any information with SPServices that isn't available. It often takes some combination of operations or some gnarly screen scraping, depending on your set up.

Jun 28, 2013 at 4:29 PM
Got it figured out - somewhat clunky but:
  1. Used the SPFindPeoplePicker to get the displayed name, then cleaned it up a bit.
  2. Passed it a SPService Query operation that was bounced against a SP2007 People Search Scope (nice to know webUrl worked with the Query service - our SP2010 search is not fully up yet!)
  3. Parsed the XML returned to get their AccountName
  4. Used the GetUserProfileByName to return the rest of the info I needed (had a separate Discussion you helped me with on that one!!)
Am in the home stretch - the rest is just pushing the values into the form fields - easy peasy!!

Here is my code in case it helps anyone in the future... I am NOT a developer, just a site owner, so if it is ugly, please forgive!! My parsing of the XML returned is very lame, but functional. I know I could use other methods, but was up against a wall...
<script src="/sites/supprt/sandbx/SCRIPTS/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="/sites/supprt/sandbx/SCRIPTS/jquery.SPServices-0.7.2.min.js" type="text/javascript"></script>
<script type="text/javascript">

// user defined variables - personField is the source for all the data extraction, other "Field" variables are the targets for the retrieved data
    var personField = "Assigned To";
    var lastNameField = "Last Name";
    var firstNameField = "First Name";
    var officeField = "Location";
    var managerNameField = "Reports To";

// declaring the remaining variables
    var assigned;
    var assignedToPeoplePicker;
    var employeeEID;
    var queryResult;
    var lastName;
    var firstName;
    var office;
    var managerName;

// PreSaveAction is called when the user hits Save - the rest of the code all lives within this function
 function PreSaveAction(){

// retrieves the PreferredName of the value entered into the personField and strips out the COC stuff - i.e. (Services-6)
   assigned = $().SPFindPeoplePicker({ peoplePickerDisplayName: personField});
   assignedToPeoplePicker = (assigned.currentValue);
   assignedToPeoplePicker = assignedToPeoplePicker.split("(");
   assignedToPeoplePicker = assignedToPeoplePicker[0];

// the users PreferredName is then passed to a SP2007 Search using the People Scope, to return their EID for use in gathering UserProfile information
   var queryText = "<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'><Query><Context><QueryText language='en-US' type='MSSQLFT'>SELECT Title, Path, Description, AccountName, Write, Rank, Size  FROM SCOPE() WHERE \"scope\" = 'People' AND PreferredName LIKE '%" + assignedToPeoplePicker + "%'</QueryText></Context><Range><StartAt>1</StartAt><Count>2</Count></Range></Query></QueryPacket>";

            operation: "Query",
            queryXml: queryText,
            webUrl: "http://idnet/sites/sharepoint",
            completefunc: function(xData, Status) {

              $(xData.responseXML).find("QueryResult").each(function() {
                 queryResult = $(xData.responseXML).find("QueryResult").text();
                 queryResult = queryResult.split("ACCOUNTNAME</Name><Type>String</Type><Value>");
                 queryResult = queryResult[1];
                 queryResult = queryResult.split("<")
                 employeeEID = queryResult[0];
                 employeeEID = employeeEID.replace(/\\/g,'\\');

/* the cleaned up EID in the format MBULOGIN\\eid (note the double backslash) is then passed to the SP2010 UserProfile service to return values.
   Acceptable values to return (although not all are used at Dominion) include:
            operation: "GetUserProfileByName",
            async: false,
            AccountName: employeeEID,
            completefunc: function (xData, Status) {
              managerName = $(xData.responseXML).SPFilterNode("PropertyData").filter(function() {
                  return $(this).find("Name").text() == "Manager";
              lastName = $(xData.responseXML).SPFilterNode("PropertyData").filter(function() {
                  return $(this).find("Name").text() == "LastName";
              firstName = $(xData.responseXML).SPFilterNode("PropertyData").filter(function() {
                  return $(this).find("Name").text() == "FirstName";
              office = $(xData.responseXML).SPFilterNode("PropertyData").filter(function() {
                  return $(this).find("Name").text() == "Office";
// now that we have gathered the values, we inject them into the fields.  THIS PORTION NOT COMPLETED YET.

return true;


Jun 28, 2013 at 5:18 PM
Edited Jun 28, 2013 at 5:24 PM
Good stuff. You might want to wrap the user profile property stuff into a little function:
firstName = getUPValue(xData.responseXML, "FirstName");
office = getUPValue(xData.responseXML, "Office");

function getUPValue(x, p) {
  var thisValue = $(x).SPFilterNode("PropertyData").filter(function() {
    return $(this).find("Name").text() == p;
  return thisValue;