Getting a single item back from a list...

Jan 23, 2012 at 9:15 PM

Working with SPServices within the Quest SharePoint web parts... which are incredibly powerful, but don't offer quite enough flexibility. In particular I'm using their qListView, which as the name suggests pulls back all entries from any number of lists and libraries. So I'm using their queries to pull back content in a specific list and library. On the front end, I'm trying to pull back the picture of the user who created the item... from the UIL, which is easy enough to do in a basic table, but when pulling back as a custom field it includes the URL to the picture, a couple of times. I have a javascript snippet to parse that and it works fine.

My problem is when combining the two technologies, Quest and SPServices, it seems neither sort works. I have a feeling it's in how my jQuery is constructed combined with the looping mechanism of the qListView. So I was wondering, is there a simple way to pass the "Created By" variable to the UIL to pull back the appropriate picture? I'm looping through all the items right now to find it. Like this:

<script language="javascript" type="text/javascript">

$(document).ready(function() {
  $().SPServices({
    operation: "GetListItems",
    listName: "User Information List",

    CAMLViewFields: "<ViewFields><FieldRef Name='Picture' /><FieldRef Name='ID' /></ViewFields>",
    CAMLQuery: "<Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'><%Created By%></Value></Eq></Where><OrderBy>Created</OrderBy></Query>",

    completefunc: function (xData, Status) {
      $(xData.responseXML).find("z\\:row, row").each(function() {
        var photo1 = "<a href='../_layouts/userdisp.aspx?ID=" + $(this).attr("ows_ID") + "' target='_blank'><img width='110' height='145' class='postedby_photo' src='" + $(this).attr("ows_Picture").split(', ')[0] + "'/></a>";

        $("#photo").append(photo1);
      });
    }
  });
});

</script>

<span id='photo'></span>

The <%Created By%> field you see is the reference to the Quest fields. Am I overcomplicating things? Is there anyway to call this as a function from within the SPAN, like via an onload?

Thanks!