I'm trying to get userinformation using the SP.UserProfiles.PeopleManagerbut when calling getMyProperties i get the error this.get_context is not a function.
I searched on the web and debugged a lot and I don't understand where the get_context of the SP.UserProfiles.PeopleManager is deifned...did not find it. In the entire SP.UserProfiles.js there is no SP.UserProfiles.PeopleManager.get_context.
Is it possible to have an explanation from Microsoft staff regarding it?
My code is the following:
var clientContext = SP.ClientContext.get_current(); var peopleManager = new SP.UserProfiles.PeopleManager(clientContext); var userProperties = peopleManager.getMyProperties(); //here I get the error
Definition of getMyProperties (Microsoft code) in SP.UserProperties.js:
getMyProperties: function() {
a: ;var a = this.get_context(), b; // get_context results always `undefined`
b = new SP.UserProfiles.PersonProperties(a,new SP.ObjectPathMethod(a,this.get_path(),"GetMyProperties",null));
return b
},Same problem using another way:
var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
var profilePropertyNames = ["PreferredName", "Department"];
var userProfilePropertiesForUser =
new SP.UserProfiles.UserProfilePropertiesForUser(
clientContext,
_spPageContextInfo.userLoginName,
profilePropertyNames);
var userProfileProperties = peopleManager.getUserProfilePropertiesFor(
userProfilePropertiesForUser);
clientContext.load(userProfilePropertiesForUser);
clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);
function onRequestSuccess() {
alert(userProfileProperties.get_displayName());
}
function onRequestFail(sender, args) {
alert("Error: " + args.get_message());
}