问题
Is it possible to get data using REST query like below:
http://moss.moss/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='user_domain\user'&$filter=DirectReports
And call by JavaScript.
I would like to create script which will check if user is a manager (has DirectReports) and next display JavaScript alert.
Thanks in advance!
回答1:
How to retrieve Manager property via SharePoint User Profiles REST API
var siteUrl = _spPageContextInfo.siteAbsoluteUrl;
var accountName = 'Domain\\Login';
$.ajax({
url: siteUrl + "/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='" + encodeURIComponent(accountName) + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
if(data.d.DirectReports.results.length > 0)
{
console.log('User has managers');
}
},
error: function (data) {
console.log(JSON.stringify(data));
}
});
来源:https://stackoverflow.com/questions/23340299/sharepoint-rest-query-sp-userprofiles-peoplemanager