Have a column in a SharePoint 2010 list set to Person or Group. Name (with Picture)

I've created JavaScript code that gets the Name, ID etc. However I also want to get the image. I've tried the code below but it outputs the name of the person, I've also tried .get_url but then an error:

The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

I am loading Photo column explicitly:

alert (oListItem.get_item('Photo').get_lookupValue());  // prints name 
alert (oListItem.get_item('Photo').get_url());   // errors

How can I get the picture url and add it to my javascript page?


1 Answer 1


You need to query the site info list. Try below code:

console.log(oListItem.get_item('Photo').get_lookupValue());  // prints name 

var userID = item.get_item('Photo').get_lookupId();


Now the getUserDetails function would be as below:

function getUserDetails(userID)
    var clientContext = new SP.ClientContext.get_current();
    var web = clientContext.get_web();
    var userInfoList = web.get_siteUserInfoList();
    var camlQuery = new SP.CamlQuery();

    camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'ID\'/>' +'<Value Type=\'Number\'>' + userID + '</Value></Eq>' +

    this.collListItem = userInfoList.getItems(camlQuery);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));

function onQuerySucceeded(sender, args)

    var item = collListItem.itemAt(0);

    var picture = item.get_item('Picture');
//could be as 
//var picture = item.get_item('PictureUrl');
function onQueryFailed(sender, args)

If you dont want this query, you can also try the below url where you can pass the account name as query string:


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.