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

How can I do this?

  • please give me a solution for 2010 :( Commented Jul 25, 2013 at 15:33

2 Answers 2


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.

  • 1
    Great Thanks a lot. But i guess it's only for Sharepoint 2013? Do we have a solution for Sharepoint 2010? Commented Jul 24, 2013 at 7:00
  • 1
    Unfortunately, there is no way to directly query the User Profile Service through JavaScript in SharePoint 2010. You can use SPService though Commented Jul 24, 2013 at 10:05
  • You can create a SOAP request and use the UserProfileService.asmx web service. Commented Jul 24, 2013 at 14:03
  • Can you please elaborate a bit @MatthewMcDermott Commented Jul 25, 2013 at 15:34
  • i Have tried this sympmarc.com/2010/10/29/… but getting an exception "Internal Server error" on google chrome console window Commented Jul 25, 2013 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

  • 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. Commented Sep 17, 2013 at 14:45
  • 1
    worked for me like charm.. thanx.. was struggling alot
    – Gaurravs
    Commented Jun 13, 2016 at 5:00
  • I need to get the Id of the manager in the same way... Is it possible?
    – Gintas K
    Commented Aug 9, 2016 at 15:07

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.