SharePoint REST query SP.UserProfiles.PeopleManager

随声附和 提交于 2019-12-11 00:36:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!