This project has moved. For the latest updates, please go here.

CAML Query problem

Feb 1, 2014 at 3:28 PM

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' />" +
    var query = "<Where>" +
                    "<Eq>" +
                        "<FieldRef Name='Assessor'></FieldRef>" +
                        "<Value Type='Integer'><UserID /></Value>" + 
                    "</Eq>" +
   alert(list + method);
    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") + "!!");

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

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