Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

SP.UserProfiles.PeopleManager this.get_context is not a function

$
0
0

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());
} 


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>