本文介绍了需要使用SP Services或任何其他Java脚本或JQuery来获取用户配置文件详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要使用SP Services或任何其他Java脚本或J查询来获取用户个人资料详细信息.

I Need to fetch User Profile Details using SP Services or any other Java Script or J Query.

我有一个列表,所有要在SharePoint页面上显示其详细信息的用户都在其中,因此我要传递用户-id或名称将被传递并获得所有必需的详细信息(部门/名称等)来自 用户个人资料,并将 在HTML中附加值以将其显示在页面上.

I have a list and where i have all the users whose details i want to display on a SharePoint page.So for that i want to pass user -id or name will be passed and will get all required details (Ex- Department/Designation etc) from  user profile and will append values in HTML for showing it on page.

请有些人帮助我实现这一目标.

Please some body help me to achieve this result. 

推荐答案

您可以利用sp.userprofiles.peoplemanager/getPropertiesFor获取特定用户的用户配置文件的所有属性.这是经过全面测试的脚本,用于获取当前用户的用户配置文件属性.在我的代码中,我得到了最新的 用户ID,然后将ID传递给profile.peoplemanager,以获取所有用户个人资料属性.

you can utilize sp.userprofiles.peoplemanager/getPropertiesFor, for getting all the properties of the user profile for specific user. here's the full tested script for getting the user profile properties of the current user. in my code, i get the current user id, then i pass the id to profile.peoplemanager for getting all user profile properties.

使用Rest API检索当前登录用户的用户配置文件属性

https://gallery.technet.microsoft.com/Retrieve-User-Profile-3762fe9e

https://gallery.technet.microsoft.com/Retrieve-User-Profile-3762fe9e

<div id="tableheader">
    <table id="tblUserProfileData" cellpadding="0" cellspacing="0">
        <thead style="background-color:#DC5807; color:White; font-weight:bold">
            <tr style="border:solid 1px #000000">
                <th style="border:solid 1px #000000">Property</th>
                <th style="border:solid 1px #000000">Value</th>
            </tr>
        </thead>
        <tbody></tbody>
    </table>
</div>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript">
SP.SOD.executeFunc('sp.js', 'SP.ClientContext',  GetPersonalURL);


function GetPersonalURL() {
var userid = _spPageContextInfo.userId;
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";

var requestHeaders = { "accept" : "application/json;odata=verbose" };




这篇关于需要使用SP Services或任何其他Java脚本或JQuery来获取用户配置文件详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 07:22