CAML Query problem

Feb 1, 2014 at 4:28 PM
Hi

I'm trying to get a value from a list based on the the current user logged in. So I'm using your wonderful SPServices and I've got it partly working. If the code below has query = "" then it works, so I have the code almost there.

Can someone please look at the query line and how I'm using it and point out what I'm doing wrong please? Apologies if it is really obvious and I'm being blind.
$(document).ready(function () {
    // Set variables up
    var method="GetListItems";
    var list="SiteList";
    var fieldsToRead="<ViewFields>" +
                        "<FieldRef Name='Title' />" +
                        "<FieldRef Name='SiteOwner' />" +
                        "<FieldRef Name='Assessor' />" +
                    "</ViewFields>";
    
    var query = "<Where>" +
                    "<Eq>" +
                        "<FieldRef Name='Assessor'></FieldRef>" +
                        "<Value Type='Integer'><UserID /></Value>" + 
                    "</Eq>" +
                "</Where>";
   alert(list + method);
  $().SPServices({
    operation: method,
    async: false,
    listName: list,
    CAMLViewFields: fieldsToRead,
    CAMLQuery: query,
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
        var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
        alert($(this).attr("ows_Title") + "!!");
        $("#tasksUL").append(liHtml);
      });
    }
  });
});
Thanks

Laura GB
Feb 1, 2014 at 5:00 PM
After looking at more examples I added <Query> tags around the query line and it worked.

L
Marked as answer by LauraGB on 2/1/2014 at 9:00 AM