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

I want to get the user's manager using Javascript Client Object model.

How can I do this?

share|improve this question
please give me a solution for 2010 :( – Varun Verma Jul 25 '13 at 15:33
up vote 0 down vote accepted

You create an instance of a manager object by using PeopleManager class in JSOM SharePoint 2013.
See the sample code below:

//Make sure SP.UserProfiles.js file is loaded before code runs.
SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js');
var userProfileProperties;

function getUserProperties() {

    // get the target users domain name and account name.
    var targetUser = "SomeDomain\\SomeUserName";

    // 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
    var profilePropertyNames = ["PreferredName", "Department"];
    var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(

    // Get user profile properties for the target user using the UserProfilePropertyFor method.
    userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);

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

// This function runs if the executeQueryAsync call succeeds.
function onRequestSuccess() {
    var messageText = "\"PreferredName\" property is "
        + userProfileProperties[0];
    messageText += "<br />\"Department\" property is "
        + userProfileProperties[1];
    $get("results").innerHTML = messageText;

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

In SharePoint 2010 and 2007, you can use SPServices library.

share|improve this answer
Great Thanks a lot. But i guess it's only for Sharepoint 2013? Do we have a solution for Sharepoint 2010? – Varun Verma Jul 24 '13 at 7:00
Unfortunately, there is no way to directly query the User Profile Service through JavaScript in SharePoint 2010. You can use SPService though – Falak Mahmood Jul 24 '13 at 10:05
You can create a SOAP request and use the UserProfileService.asmx web service. – Matthew McDermott Jul 24 '13 at 14:03
Can you please elaborate a bit @MatthewMcDermott – Varun Verma Jul 25 '13 at 15:34
i Have tried this… but getting an exception "Internal Server error" on google chrome console window – Varun Verma Jul 25 '13 at 15:41
var managerName;
    operation: "GetUserProfileByName",
    async: false,
    AccountName: $().SPServices.SPGetCurrentUser(),
    completefunc: function (xData, Status) {
      $(xData.responseXML).find("PropertyData > Name:contains('Manager')").each(function() {
        managerName = $(this).parent().find("Values").text();
        alert(managerName );

The Above is the code used.

I want manger in alert. Version of the sharepoint Microsoft SharePoint Server 2010 not foundation.

@Falak Mahmood. Please help. I am getting this exception in google chrome

POST url/_vti_bin/UserProfileService.asmx 500 (Internal Server Error) jquery-1.8.2.min.js:2 send jquery-1.8.2.min.js:2 p.extend.ajax jquery-1.8.2.min.js:2 Q.fn.SPServices jquery.SPServices-0.7.1a.min.js:19 (anonymous function) made.js:25 k jquery-1.8.2.min.js:2 l.fireWith jquery-1.8.2.min.js:2 p.extend.ready jquery-1.8.2.min.js:2 D

share|improve this answer
I know this post is old, but I just tried this code in Firefox and Chrome and it worked fine. There must be something else going on. – Marc D Anderson Sep 17 '13 at 14:45
Thanks @MarcDAnderson i am still trying to figure out. – Varun Verma Sep 19 '13 at 5:57
worked for me like charm.. thanx.. was struggling alot – Gaurravs Jun 13 at 5:00

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.