This project has moved and is read-only. For the latest updates, please go here.

GetUserProfileByName issues with SPServices-0.7.2.min.js & jquery-1.8.3.min.js

Jun 27, 2013 at 10:07 PM
The code below works with older versions of jQuery and SPServices; but not with the references versions - what syntax am I messing up?

    operation: "GetUserProfileByName",
    async: false,
    AccountName: "MBULOGIN\\will266",
    completefunc: function (xData, Status) {
      managerName = $(xData.responseXML).find("PropertyData > Name[text='Manager']").parent().find("Values").text();
      pName = $(xData.responseXML).find("PropertyData > Name[text='PreferredName']").parent().find("Values").text();
      EID = "MBULOGIN\\" + $(xData.responseXML).find("PropertyData > Name[text='UserName']").parent().find("Values").text();
      wPhone = $(xData.responseXML).find("PropertyData > Name[text='WorkPhone']").parent().find("Values").text();

Jun 27, 2013 at 10:49 PM
Edited Jun 27, 2013 at 10:49 PM
Your sample didn't work in my environment, so I whipped this up. Of course, I tested it with a valid account on my end.
  operation: "GetUserProfileByName",
  async: false,
  AccountName: "MBULOGIN\\will266",
  completefunc: function (xData, Status) {
    managerName = $(xData.responseXML).SPFilterNode("PropertyData").filter(function() {
        return $(this).find("Name").text() == "Manager";
Give it a go.

Jun 28, 2013 at 2:59 PM
Awesome - that worked like a charm. Still unsure about when to/how to use SPFilterNode. I know that z row was deprecated in a release of jQuery, but since I saw no reference to that in my code which worked with earlier jQuery, was not sure how to correct.

This would make a great simple sample in the documentation!!

Thanks so much!!

Jun 28, 2013 at 5:03 PM
Edited Jun 28, 2013 at 5:03 PM

SPFilterNode is really only required to deal with the namespaces using the colons, like z:row and rs:data. I've gotten in the habit of using it more than that, but it's not required. I don't think there's any significant performance trade off.

I will add it as an example!

Nov 7, 2013 at 2:40 PM
Now what would you do for "string (Multi Value)" type fields like SPS-PastProjects?
I was hoping to see the ";" delimiter so I can use .split but instead the value comes as bunch of strings.

maybe .find("Values").each will give me an array?
Nov 7, 2013 at 2:48 PM
Aren't the "bunch of strings" delimited in some way? I don't have any data that I can look at for this.

Nov 7, 2013 at 3:07 PM
When you edit the property it shows ";" as the delimiter but when I use something like:
        var PastProjects = $(xData.responseXML).SPFilterNode("PropertyData").filter(function() {    return $(this).find("Name").text() == "SPS-PastProjects";}).find("Values").text();
        alert (PastProjects);
it shows the strings without the delimiter. I am assuming the text() function just concatenates the array items and my jQuery skills are not too good to figure out how to get an array from this

var PastProjectsArray = $(xData.responseXML).SPFilterNode("PropertyData").filter(function() { return $(this).find("Name").text() == "SPS-PastProjects";}).find("Values")
make PastProjectsArray an array?
guess I can test :-)
Nov 7, 2013 at 3:11 PM
Take a look at what this returns:
        var PastProjects = $(xData.responseXML).SPFilterNode("PropertyData").filter(function() {
          return $(this).find("Name").text() == "SPS-PastProjects";
        alert (PastProjects);
Nov 7, 2013 at 3:39 PM
Edited Nov 7, 2013 at 6:43 PM
that gave me:
"<ValueData xmlns="">
<Value xsi:type="xsd:string" xmlns:xsi="">Project #1</Value>
<ValueData xmlns="">
<Value xsi:type="xsd:string" xmlns:xsi="">Project #2</Value>
<ValueData xmlns="">
    <Value xsi:type="xsd:string" xmlns:xsi="">Project #3</Value>

now I need to figure out how to make an Array with the 3 projects { Project #1 ; Project #2 ; Project #3 }

Thanks in advance
Nov 7, 2013 at 6:45 PM
Turns out I did not have success figuring hoe to make an array out of the XML of in the "PastProjects" variable.
Any advice?
Nov 8, 2013 at 8:31 PM
Try this for converting the <Value> xml elements into an array that contains the value within the XML:
pastProjects = (function(){
    var projArray = [];
        .filter(function() {
            return $(this).find("Name").text() == "SPS-PastProjects";
        .find("Values Value")
                projArray.push( $(this).text() );
    return projArray;
I did not test this in a live environment and is only a example that should work given the data you posted above.

The following should alert you with "Project #1" if it all works out:
alert( pastProjects[0] );
Nov 8, 2013 at 10:05 PM
Thanks Paul
I actually solved it but for got to post
var PastProjects = $(xData.responseXML).SPFilterNode("PropertyData").filter(function() {return $(this).find("Name").text() == "Bax-PastProjects";}).find("ValueData");
for (var i=0;i<PastProjects.length;i++)
        $("#PastProjectsTable tbody").append( propertyRow( $(PastProjects[i]).text() ) );

works fine because PastProjects is an Array itself
but I think your solution might be more elegant!