我试图显示用户缺少哪些用户配置文件属性来填写。获取 usersprofile 和 userprofile 属性相当容易:
function getUserPropertiesFromProfile() {
// Get the current client context and PeopleManager instance.
var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
// Get user profile properties for the current user
userProfileProperties = peopleManager.getMyProperties();
// Load the UserProfilePropertiesForUser object and send the request.
clientContext.load(userProfileProperties);
clientContext.executeQueryAsync(onProfileRequestSuccess, onProfileRequestFail);
}
function onProfileRequestSuccess() {
var propertyValue = userProfileProperties.get_userProfileProperties()["SPS-JobTitle"];
if (propertyValue === undefined) {
// Property is not present in your User Profile Service Application
}
else if (propertyValue === "") {
// Property is empty
}
}
function onProfileRequestFail() {
// Handle failure
}
但我的问题是它是我得到的内部名称,而不是外部名称。例如,“职位”是“SPS-JobTitle”。所以我想要的是,如果“SPS-JobTitle”为空或未定义,那么我想将外部名称 =“Job Title”写给用户。
有可能吗?我知道这在 SSOM 中很容易(例如 ProfileSubtypeManager)。