SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As part of my Sharepoint hosted App i am using a list which contains a Person or Group. I am getting the ID of the person by using the following.

var ApproverID = currentItem.get_fieldValues()["Approver"].get_lookupId();

From here i now want to get the persons name or "DisplayText" but can find anything client side that does this in MSDN.

Can this be done?

share|improve this question
up vote 3 down vote accepted

I assume in your example Approver is a User field type. In SharePoint 2013 CSOM SP.FieldUserValue object represents the value of a user field for a list item.

The following code demonstrates how to get User Name from User field:

//Get user field value
var assignedToVal = item.get_item('AssignedTo');
var userName = assignedToVal.get_lookupValue();   

//Get multi user field value
var assignedToVals = item.get_item('AssignedTo');
for(var i = 0; i < assignedToVals.length;i++) {
     var userName = assignedToVals[i].get_lookupValue();   
share|improve this answer
doesn't show how to get it via User ID. Is that even possible? – hitdrumhard Jul 31 '14 at 18:30
@hitdrumhard yes just use get_lookupId() instead – Maurizio Pozzobon Mar 25 at 13:26

You need to reference following JavaScript file:

<SharePoint:ScriptLink ID="ScriptLink2" name="SP.UserProfiles.js" runat="server"
    ondemand="false" localizable="false" loadafterui="true" />

Than you can access the User Profile Properties as follows:

var personProperties;

// Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js');

function getUserProperties() {

    // Replace the placeholder value with the target user's credentials.
    // var targetUser = "domainName\\userName";
    var targetUser = currentItem.get_fieldValues()["Approver"].get_lookupValue();

    // Get the current client context and PeopleManager instance.
    var clientContext = new SP.ClientContext.get_current();
    var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

    // Get user properties for the target user.
    // To get the PersonProperties object for the current user, use the
    // getMyProperties method.
    personProperties = peopleManager.getPropertiesFor(targetUser);

    // Load the PersonProperties object and send the request.
    clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);

// This function runs if the executeQueryAsync call succeeds.
function onRequestSuccess() {

    // Get a property directly from the PersonProperties object.
    var messageText = " \"DisplayName\" property is "
        + personProperties.get_displayName();

    // Get a property from the UserProfileProperties property.
    messageText += "<br />\"Department\" property is "
        + personProperties.get_userProfileProperties()['Department'];
    $get("results").innerHTML = messageText;

// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
    $get("results").innerHTML = "Error: " + args.get_message();


How to: Retrieve user profile properties by using the JavaScript object model in SharePoint 2013

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.