1

In Sharepoint 2010 I am getting display name of the user with SPServices like 11;#John, Kondo. But I want account name like mydomain\aa2311. Is there any way to get the account name with the display name property? Not for the currently logged in user. I am having one person or group column in sharepoint list. I am getting values from this column. It is giving like 11;#John Kondo Following is the code :

 var getListItemsFrom= function(listName, viewFields, queryText, rowCount, queryOptions, asyncBool){
            var deferred = $.Deferred();
            $().SPServices({
                    operation:"GetListItems",
                    async: asyncBool,
                    listName:listName,
                    CAMLRowLimit:100,
                    CAMLQuery:queryText,
                    CAMLViewFields:viewFields,
                    completefunc:function(data){
                        deferred.resolve(data);
                    }
                });
            return deferred;
        };
getListItemsFrom("Demand Requests",viewFields ,query,0,"",true).then(function(data){
        $(data.responseXML).SPFilterNode("z:row").each(function(ind,elm){
       var requestorAccountIds = $(this).attr('ows_Requestor');//ows_Requestor is person or group field

});
});
3
2

You can expand the user field using following code

CAMLQueryOptions: "<QueryOptions><ExpandUserField>True</ExpandUserField></QueryOptions>"

Now you can extract username in success method by using string manipulation.

5
  • Not for the current user. – Mihir Apr 14 '15 at 14:53
  • Updated with code. – Mihir Apr 14 '15 at 15:00
  • This is giving me strange result like 11;#John,, Kondo,#i:0#.w|abl\ab14431,#John.Kondo@centurylink.com,#John.Kondo@CenturyLink.com,#John,, Kondo. It is having two commas between user display name. Do you know why? – Mihir Apr 14 '15 at 15:13
  • It might be user middle name.. You can split this result usin | and then take the second part. Split it by comma and take first part.. tat will give you abl\ab14431 – Amal Hashim Apr 14 '15 at 15:16
  • Yeah this is fine. But if you observe display name like11;#John,,Kondo giving two commas. You meant to say this is happening because of middle name is empty? – Mihir Apr 14 '15 at 15:18

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.