var users=["domain\\kalpeshp", "domain\\sachinka", "domain\\nikhils"];
function GetUserProperties(clientContext, peopleManager, targetUser, profilePropertyNames){
var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(
clientContext,
targetUser,
profilePropertyNames);
var userProfileProps = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);
clientContext.load(userProfilePropertiesForUser);
clientContext.executeQueryAsync(
function () { console.log(userProfileProps[0] + " works in " + userProfileProps[1] + " as a " + userProfileProps[2]); },
function () { console.log("Failure") });
}
function GetAllUserProperties(){
var targetUser = "domain\\kalpeshp";
// Create the client context and get the PeopleManager instance.
var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
// Get user profile properties for the target user.
// Specify the properties to retrieve and create the UserProfilePropertiesForUser object.
// Then get the requested properties by using the getUserProfilePropertiesFor method.
var profilePropertyNames = ["PreferredName", "Department", "Title"];
for(var i=0; i<users.length;i++){
GetUserProperties(clientContext, peopleManager, users[i], profilePropertyNames);
}
}
function GetUserProperties(clientContext, peopleManager, targetUser, profilePropertyNames){
var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(
clientContext,
targetUser,
profilePropertyNames);
var userProfileProps = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);
clientContext.load(userProfilePropertiesForUser);
clientContext.executeQueryAsync(
function () { console.log(userProfileProps[0] + " works in " + userProfileProps[1] + " as a " + userProfileProps[2]); },
function () { console.log("Failure") });
}
function GetAllUserProperties(){
var targetUser = "domain\\kalpeshp";
// Create the client context and get the PeopleManager instance.
var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
// Get user profile properties for the target user.
// Specify the properties to retrieve and create the UserProfilePropertiesForUser object.
// Then get the requested properties by using the getUserProfilePropertiesFor method.
var profilePropertyNames = ["PreferredName", "Department", "Title"];
for(var i=0; i<users.length;i++){
GetUserProperties(clientContext, peopleManager, users[i], profilePropertyNames);
}
}
No comments:
Post a Comment