2

I'm trying to get some user properties and alert them (I'm going to put them i labels later but just for now I'm using alert). I'm using a content editor with this code:

     SP.SOD.executeFunc('sp.js','SP.ClientContext',runthiscode);
    function runthiscode()
    {   
            SP.SOD.executeFunc('SP.UserProfiles.js','SP.UserProfiles',getUserProperties);
    }
    var personProperties;
        function getUserProperties() {  

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

            personProperties = peopleManager.getMyProperties();

            clientContext.load(personProperties);
            clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);
        }

        function onRequestSuccess() {       

          alert(personProperties.get_displayName());
          alert(personProperties.get_pictureUrl());
          alert(personProperties.get_loginName());

        }

        function onRequestFail(sender, args) {
          alert("error msg");
        }

The alert with loginName doesn't work, why is that? Why can I get pictureUrl and displayName but no other properties? Is there any list of properties available for reference?

1
  • Try get_accountName(), I hope this will work Commented May 6, 2014 at 13:19

1 Answer 1

2

The method SP.UserProfiles.PeopleManager.getPropertiesFor returns SP.UserProfiles.PersonProperties object. You could find the list of properties for PersonProperties object here and there is no property named LoginName.

Probably you need to retrieve property named accountName:

var value = SP.UserProfiles.PersonProperties.get_accountName()

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.