I am looking to grab user information to auto populate fields in a custom form. InfoPath is out of the question so it needs to be done through JavaScript. This article is close to what I need but I need some assistance in getting it correct. The fields I need to tap into are the username, phone extension and division. These are all fields in the under the user profile information. I have copied the code here. I don't understand it completely so I am looking for guidance to capture, display and save the data within the form.
function GetPeople(){
var acctName; // stores the login
var assigned; // value from people picker field
var workPhoneExt; // stores assigned's work phone
var personDivision; // stores the login
// Get people picker value
assigned = $().SPServices.SPFindPeoplePicker({
peoplePickerDisplayName: personField,
checkNames: true
});
// intiate check names - don't have to do another timeout here as we should already
// have proper values here, simply doing it again as a secondary check
assigned.checkNames.click();
// get the users email from the SPFindPeoplePicker dictionary
acctName = assigned.dictionaryEntries[0].AccountName;
// Get user information
$().SPServices({
operation: "GetUserProfileByName",
async: false,
AccountName: acctName,
completefunc: function (xData, Status) {
wworkPhoneExt = getUPValue(xData.responseXML, "Extension");
}
});
// fill out the text boxes with information
getField('input','Contact Email').value = userEmail;
getField('input','Phone Extension').value = workPhoneExt;
}
// gets the value of the called profile field
function getUPValue(x, p) {
var thisValue = $(x).SPFilterNode("PropertyData").filter(function() {
return $(this).find("Name").text() == p;
}).find("Values").text();
return thisValue;
}