I'm trying to query the User Profile for the current logged in user. Per examples I've seen, I should reference the SP.UserProfiles.js file in my executeOrDelay call:

SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js');

But when I do, I get the following error, and nothing happens:

Uncaught TypeError: Cannot read property 'parentElement' of null at RTE.Canvas.checkCurrentFocus (VM13459 sp.ui.rte.js:2)

When I change the reference to just plain sp.js instead of SP.UserProfiles.js, I get an error "cannot read property 'PeopleManager' of undefined

var clientContext= new SP.ClientContext.get_current(); var peopleManager= new SP.UserProfiles.PeopleManager(clientContext);

on the peopleManager variable. I realize that it can't read the PeopleManager because I haven't explicitly loaded the SP.UserProfiles.js file, but why would it just do nothing when I call it outright? Do I need to split this up into two separate actions, one to just get the context (and therefore the current user), and then from within the context do a second call to the UserProfiles.js to get the user profile info?

1 Answer 1


Maybe in the first case it does nothing because the 'SP.UserProfiles.js' file is not referenced and as the result the executeOrDelayUntilScriptLoaded function never calls your code.

I would suggest to use the "executeFunc" method to make sure that both files (sp.js and SP.UserProfiles.js) have been loaded and executed, and then run your code. The difference between executeOrDelayUntilScriptLoaded and executeFunc is that the latter ensures that the file is loaded.

SP.SOD.executeFunc('SP.js', 'SP.ClientContext', function() { 
   SP.SOD.executeFunc('userprofile', 'SP.UserProfiles.PeopleManager', getUserProperties);

function getUserProperties(){
  var ctx = new SP.ClientContext.get_current();
  var peopleManager = new SP.UserProfiles.PeopleManager(ctx);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.