How can I access the properties of a user that I've targeted? I think I have a good context setup, as well as a good peopleManager object, but when I try to grab properties for a targeted individual, I keep getting exceptions. According to a colleague of
mine I should have all the permissions I need and then some to see anyone's properties. So I'm at a loss to explain why I can't get at them. Here's the code for the three methods involved:
function getUserProperties()
{
try
{
var targetUser = "https://testportal.stchas.edu/\\ppender";
var prprtsCntxt = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(prprtsCntxt);
personProperties = peopleManager.getPropertiesFor(targetUser);
prprtsCntxt.load(personProperties);
prprtsCntxt.executeQueryAsync(Function.createDelegate(this,function(){showPersonProperties(personProperties);}), personPropertiesQueryFailed);
}
catch(excptn)
{
console.log("METHOD: 'getUserProperties' - Exception: '"+ excptn.name + "' - " + excptn.message);
alert("METHOD: 'getUserProperties' - Exception: '"+ excptn.name + "' - " + excptn.message);
}
finally
{
}
}
function showPersonProperties(personProperties)
{
try
{
//var trgtPrprts = personProperties.get_clientObjectProperties();
var trgtPrprts = personProperties.get_userProfileProperties();
//var messageText = " \"DisplayName\" property is " + personProperties.get_userProfileProperties();
//messageText += "<br >\Department\" property is " + personProperties.get_userProfileProperties()['Department'];
//console.log(messageText);
//alert(messageText);
}
catch(excptn)
{
console.log("METHOD: 'showPersonProperties' - Exception: '"+ excptn.name + "' - " + excptn.message);
alert("METHOD: 'showPersonProperties' - Exception: '"+ excptn.name + "' - " + excptn.message);
}
finally
{
}
}
function personPropertiesQueryFailed(sender, args)
{
try
{
console.log("Error: ("+args.get_message()+").");
}
catch(excptn)
{
console.log("METHOD: 'personPropertiesQueryFailed' - Exception: '"+ excptn.name + "' - " + excptn.message);
alert("METHOD: 'personPropertiesQueryFailed' - Exception: '"+ excptn.name + "' - " + excptn.message);
}
finally
{
}
}
The code currently keeps failing on the only line of active code in the "showPersonProperties" method shown above.
Am I missing something obvious on how to do this?
Thanks for the help.
Henry