Last active
October 27, 2016 08:02
-
-
Save Aymkdn/da1e498690dc9b957ea4f5c93a1a05a7 to your computer and use it in GitHub Desktop.
Examples to retrieve a manager in Sharepoint 2013
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Retrieve Manager for a username | |
// using REST API | |
var siteUrl = _spPageContextInfo.siteAbsoluteUrl; | |
var accountName = 'domain\\login'; | |
// I suppose you use jQuery | |
$.ajax({ | |
url: siteUrl + "/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='" + encodeURIComponent(accountName) + "'", | |
method: "GET", | |
headers: { "Accept": "application/json; odata=verbose" }, | |
success: function (data) { | |
alert("The manager username is:" + data.d.ExtendedManagers.results.slice(-1)[0]); | |
}, | |
error: function (data) { | |
console.log(JSON.stringify(data)); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Retrieve Manager for the current user | |
// using REST API | |
var siteUrl = _spPageContextInfo.siteAbsoluteUrl; | |
$.ajax({ | |
url: siteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties", | |
method: "GET", | |
headers: { "Accept": "application/json; odata=verbose" }, | |
success: function (data) { | |
alert("The manager username is: " + data.d.ExtendedManagers.results.slice(-1)[0]) | |
}, | |
error: function (data) { | |
console.log(JSON.stringify(data)); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Retrieve Manager for a username | |
// using SharepointPlus -- http://aymkdn.github.io/SharepointPlus/symbols/%24SP%28%29.html#.people | |
var username = "domaine\\login"; | |
$SP().people(username, function(people) { | |
alert("The manager username is: " + people["Manager"]) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Retrieve Manager for the current user | |
// using SharepointPlus -- http://aymkdn.github.io/SharepointPlus/symbols/%24SP%28%29.html#.whoami | |
for the $SP().whoami(function(people) { | |
alert("The manager username is: " + people["Manager"]) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment