【问题标题】:How to get Display name of user profile manager property如何获取用户配置文件管理器属性的显示名称
【发布时间】:2016-03-03 01:25:50
【问题描述】:
当我为 SharePoint 人员搜索编写自定义显示模板时,我想显示搜索用户的经理。当我显示从 SharePoint 人员搜索返回的经理值时,它显示如下:
i:0#.f|membership|lpalmer@xyz.com
我想在我的 SharePoint 显示模板中显示而不是帐户名。让我知道这是否可以使用 JavaScript 或仅通过对 SharePoint 用户配置文件属性更改进行一些配置来完成。
【问题讨论】:
标签:
sharepoint-2013
sharepoint-online
sharepoint-userprofile
【解决方案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);
}
});
}
-希望对你有帮助