1

当我为 SharePoint 人员搜索编写自定义显示模板时,我想显示搜索用户的经理。当我显示从 SharePoint 人员搜索返回的经理值时,它显示如下:

i:0#.f|会员|lpalmer@xyz.com

我想在我的 SharePoint 显示模板中显示显示而不是帐户名称。让我知道这是否可以使用 JavaScript 或仅通过对 SharePoint 用户配置文件属性更改进行一些配置来完成。

4

1 回答 1

1

这不能仅使用配置来完成。您将需要查询用户配置文件服务并使用搜索服务返回的登录名获取显示名称。

要获得任何属性,您可以使用以下内容:

function getProfilePropertyValueFromLoginName(loginName, propertyName, success, error) {
            // Get the current client context and PeopleManager instance.
            var clientContext = new SP.ClientContext.get_current();
            var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

            // Get user properties for the target user.
            // To get the PersonProperties object for the current user, use the
            // getMyProperties method.
            var personProperties = peopleManager.getPropertiesFor(loginName);

            // Load the PersonProperties object and send the request.
            clientContext.load(personProperties);
            clientContext.executeQueryAsync(
                function () {

                    if (success) {
                        success(loginName, personProperties.get_userProfileProperties()[propertyName]);
                    }
                }, function (sender, args) {
                    if (error) {
                        error(sender, args);
                    }
                });
        }

-希望能帮助到你

于 2016-03-02T17:25:50.777 回答