I am creating one javascript file to bring all users emails and birthdates using JSOM.

var targetUser = elm; // elm is my user name eg:i:0#.f|membership|[email protected] 
    // Get the current client context and PeopleManager instance.
    var clientContext = new SP.ClientContext.get_current();
    var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

    // Specify the properties to retrieve and target user for the 
    // UserProfilePropertiesForUser object.
    var profilePropertyNames = ["PreferredName", "Department","WorkEmail"];
    var userProfilePropertiesForUser = 
        new SP.UserProfiles.UserProfilePropertiesForUser(

    // Get user profile properties for the target user.
    // To get the value for only one user profile property, use the
    // getUserProfilePropertyFor method.
    userProfileProperties =(peopleManager.getUserProfilePropertiesFor(

    // Load the UserProfilePropertiesForUser object and send the request.
    clientContext.executeQueryAsync(OnQuerySuccess, OnQueryFail);

//success function
function OnQuerySuccess(data){


It is going to OnQuerySuccess method. If I log the data object it is showing string like SP.ClientRequest {$$d_$3C_0: function, $16_0: Array[4], $1L_0: Object, $0_0: SP.ClientContext, $P_0: SP.ClientQueryInternal…} I unable to know how to iterate through this collection. Even I try to implement the following said solutions. http://msdn.microsoft.com/en-us/library/office/jj920104(v=office.15).aspx http://www.vrdmn.com/2013/07/sharepoint-2013-get-userprofile.html

I am attaching image how that data object is looking. enter image description here

When I log the user profile properties I am getting value in console like below enter image description here

  • Can you add the success handler?
    – wjervis
    Jun 12, 2014 at 15:11
  • Yes added... in success handler only I am getting this output.
    – Mihir
    Jun 12, 2014 at 15:19
  • Try accessing userProfileProperties within your success handler.
    – wjervis
    Jun 12, 2014 at 15:33
  • Sorry @wjervis, I didn't get you
    – Mihir
    Jun 13, 2014 at 4:10
  • Your success handler is using data. Remove the parameter, and instead just log userProfileProperties, and see what values are in it, as in Aveenav's answer.
    – wjervis
    Jun 13, 2014 at 17:30

2 Answers 2

//success function
    function OnQuerySuccess(data){
     window.console && console.log(userProfileProperties);
     window.console && console.log('Success');
     var prefName= "Preferred Name: " + userProfileProperties[0];
     window.console && console.log(prefName);     

     var dept = "Department: " + userProfileProperties[1];
     window.console && console.log(dept);     

     var email = "Email: " + userProfileProperties[2];
     window.console && console.log(email);      

You can comment out this line

  • Even i tried this solution also. But no use. I have total 5 user profiles. When I log the userProfilePoperties it is giving 4 empty arrays and one array with only "PreferredName" value, other values like "SPS-Birthday", "PictureURL" etc not coming in the output.
    – Mihir
    Jun 13, 2014 at 4:09
  • You'd need to include properties SPS-Birthday and PictureURL to your array var profilePropertyNames = ["PreferredName", "Department","WorkEmail", "SPS-Birthday", "PictureURL"]; If you're still unsuccessful at retrieving properties with CSOM, try the rest API: _api/SP.UserProfiles.PeopleManager/GetMyProperties
    – Aveenav
    Jun 13, 2014 at 17:29

The following example works for me

var targetUser = 'i:0#.f|membership|[email protected]'; 
var context = SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(context);

var profilePropertyNames = ["PreferredName", "Department","WorkEmail"];
var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(
var userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);


    //print user profile properties

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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