Hi,
i am having a problem with GetUserProfileByName. ill explain what i am actually trying to accomplish and then ill explain my problem.
i have an input field that on keydown it searches profile Service and returns the staff member that is close to that name that you are typing.
problems: when i try search for a name like John i get no results back, but when i put John.Martinez i get back results. is there a way for me to fix that? i want it to search by last name or first name. what ever the user starts typing.
i want the result to just return 5 records at a time until it gets to only one. how can i do that. below is the code i am using. i actually used the code that i found here and modified it so that it can do what i want it to do.
i am having a problem with GetUserProfileByName. ill explain what i am actually trying to accomplish and then ill explain my problem.
i have an input field that on keydown it searches profile Service and returns the staff member that is close to that name that you are typing.
problems: when i try search for a name like John i get no results back, but when i put John.Martinez i get back results. is there a way for me to fix that? i want it to search by last name or first name. what ever the user starts typing.
i want the result to just return 5 records at a time until it gets to only one. how can i do that. below is the code i am using. i actually used the code that i found here and modified it so that it can do what i want it to do.
<input name="userSearch" type="text" id="userSearch" onkeydown="getStaffInformation(this.value)" /><br/><br/>
<div id="staffInformationList"> </div>
function getStaffInformation(name)
{
$().SPServices({
operation: 'GetUserProfileByName',
AccountName: name,
async:false,
completefunc: function (xData, Status)
{
var properties = xData.responseXML.getElementsByTagName('PropertyData');
var propertyValues = new Array();
for(var i=0; i < properties.length; i++)
{
var propName = properties[i].getElementsByTagName('Name')[0].childNodes[0].nodeValue;
propertyValues[propName] = properties[i].getElementsByTagName('Value');
var oValueNode = properties[i].getElementsByTagName('Value');
if(oValueNode.length > 0)
{
propertyValues[propName] = oValueNode[0].childNodes[0].nodeValue;
}
else
{
propertyValues[propName] = '';
}
}//end of for loop
var searchName = propertyValues['PreferredName'];
var seachTitle = propertyValues['Title'];
var searchEmail = propertyValues['WorkEmail'];
var searchPhoto = propertyValues['PictureURL'];
var searchPhone = propertyValues['WorkPhone'];
//alert(searchName);
var seachInformation = "<li>"
+"<table width=\"250\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
+"<tr>"
+"<td width=\"48\" rowspan=\"3\" valign=\"top\">"+
+"<div class=\"searchPicture\"><img alt=\"\" src=\""+searchPhoto+"\" /></div>"
+"</td>"
+"<td width=\"154\" height=\"16\" valign=\"top\">"+searchName+"</td>"
+"<td width=\"44\" rowspan=\"2\" align=\"right\" valign=\"top\">"
+"<a href=\"mailto:"+searchEmail+"\"><img src=\"/sites/247Dev/SiteAssets/images/email.png\" width=\"22\" height=\"15\" alt=\"Email\" border=\"0\" /></a>"
+"</td>"
+"</tr>"
+"<tr>"
+"<td height=\"16\" valign=\"top\">"
+"<span class=\"searchTitle\">"+seachTitle+"</span>"
+"</td>"
+"</tr>"
+"<tr>"
+"<td valign=\"16\">"
+"<span class=\"searchPhone\">"+searchPhone+"</span>"+
+"</td>"
+"<td valign=\"top\"> </td>"
+"</tr>"
+"</table>"
+"</li>";
$('#staffInformationList').append(seachInformation);
}//end of comple function
});//end of spservices
}//end of function