I am trying to get current user profile information using the PeopleManager object ( SP.UserProfiles.js ) in a SharePoint hosted app. Code snippet is like below :
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
var userProperties = peopleManager.getMyProperties();
But, the peopleManager.getMyProperties() call gives an error "undefined is not a function"
The SP.UserProfiles.js is loaded correctly.
Whole Code:
var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
// error occurs at this line
var userProfileProperties = peopleManager.getMyProperties();
clientContext.load(userProfileProperties);
clientContext.executeQueryAsync(
function() {
// do nothing
},
function(){
// do nothing
}
);
The error occurs even before calling
clientContext.load(userProfileProperties);
So, it looks like the issue might not be while loading the object by client context.
How can I resolve this issue?
clientContext
? Is this a SharePoint Hosted app? If so, you need to use theSP.RequestExecutor.js
library.