I have a persons field in a list which displays the Users Name (Not userid/Account name)
On another site within the same site collection I can retrieve this information but I need to query UPS and display the Photo of the user.
I've looked at the following but the image is not being returned (I've altered the domain\userid) https://msdn.microsoft.com/en-us/library/office/jj920104.aspx
I'm running sharepoint 2010
Thanks
UPDATE
<asp:Content id="Content1" runat="server" contentplaceholderid="PlaceHolderMain">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript">
// Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
var personProperties;
SP.SOD.executeOrDelayUntilScriptLoaded(GetProfilePicture, 'SP.js','SP.UserProfiles.js');
function GetProfilePicture(){
var userName="wl_dom1\\tim dalton";
var soapEnv =
"<?xml version='1.0' encoding='utf-8'?> \
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \
<soap:Body> \
<GetUserProfileByName xmlns='http://microsoft.com/webservices/SharePointPortalServer/UserProfileService'> \
<AccountName>"+ userName +"</AccountName> \
</GetUserProfileByName> \
</soap:Body> \
</soap:Envelope>";
$(function() {
//Chech jQuery loaded
$.ajax({
url: "http://share.lilondon.com/sites/arsitecoll/_vti_bin/userprofileservice.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\""
});
});
}
function processResult(xData, status) {
var results = $(xData.responseXML);
console.log(results);
var elmValue = results.getElementsByTagName("Value");
var pictureUrl;
//you will have to iterate through xml to find PictureUrl name and value
for (i = 0; i < elmValue.length; i++) {
if (elmValue[i].parentNode.parentNode.parentNode.childNodes[2].text =='PictureUrl') {
pictureUrl = elmValue[i].childNodes[0].nodeValue;
break;
}
}
console.log(pictureUrl);
}
</script>
Note I've added '$(function() {'
Error SCRIPT438: Object doesn't support property or method 'addEventListener' File: jquery.min.js, Line: 2, Column: 29928
SCRIPT5007: The value of the property '$' is null or undefined, not a Function object
I then changed jQuery version to 1.10.2 and tried other 1.x.x versions and get a new error. So thing any version above 1 adds addition issues, maybe because of the browser or sp2010.
Object doesn't support property or method 'getElementsByTagName'