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:

    function runthiscode()
    var personProperties;
        function getUserProperties() {  

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

            personProperties = peopleManager.getMyProperties();

            clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);

        function onRequestSuccess() {       



        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?


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()
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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