CAMLQuery filter not working

Mar 28, 2013 at 9:19 AM
I would appreciate some help. I have a really successful map going. It uses spservices GetListItems wonderfully to return everything and put it on the map. But I sure would like to filter for Status=Closed items. Here is the code. If I comment the CAMLQuery:... line it runs perfectly.
    function getlocations() {
        //RETRIEVE DATA FROM SHAREPOINT LIST
        $().SPServices({ 
            operation: "GetListItems", 
            async: false, 
            listName: "Event List Free",
            CAMLQuery: "<Query><Where><Eq><FieldRef Name="Status" /><Value Type="Choice">Closed</Value></Eq></Where></Query>",
            completefunc: function (xData, Status) { 
            alert(xData.responseXML.xml);
                $(xData.responseXML).SPFilterNode("z:row").each(function() {
                //BUILDING MY VARIABLES FROM MY LIST COLUMNS
                var myTitle = $(this).attr('ows_Alert_x0020_Type');
                var myLong = $(this).attr('ows_Longitude');
                var myLat = $(this).attr('ows_Latitude');
                var myStatus = $(this).attr('ows_Status');
                var myRegion = $(this).attr('ows_Event_x0020_Type');
                var myManned = $(this).attr('ows_Lead_x0020_Region');
                var myLink = $(this).attr('ows_Link');
                var myInfo = "<table>" +
            "<tr><td><b>Type  </b></td><td>" + myTitle + "</td></tr>" +
            "<tr><td><b>Latitude</b></td><td>" + myLat + "</td></tr>" +
            "<tr><td><b>Longitude</b></td><td>" + myLong + "</td></tr>" +
            "<tr><td><b>Event  </b></td><td>" + myRegion + "</td></tr>" +
            "<tr><td><b>Lead  </b></td><td>" + myManned + "</td></tr></table>" +
            "<tr><td><b>Status  </b></td><td>" + myStatus + "</td></tr></table>"
            "<tr><td><b>Link</b></td><td>" + myLink + "</td></tr></table>"          
            //var myPicture = $(this).attr('ows_Picture');
            //PUSH ALL VARIABLES INTO ARRAY
        funclocations.push([myTitle, myLong, myLat, myRegion, myManned, myStatus, myLink, myInfo]);
                }); 
            } 
       });
        return funclocations;
    }
Coordinator
Mar 28, 2013 at 1:08 PM
It could be as simple as your quotes. You're using double quotes inside double quotes without escaping them. Two options:
            CAMLQuery: "<Query><Where><Eq><FieldRef Name=\"Status\" /><Value Type=\"Choice\">Closed</Value></Eq></Where></Query>",
or
            CAMLQuery: "<Query><Where><Eq><FieldRef Name='Status' /><Value Type='Choice'>Closed</Value></Eq></Where></Query>",
I tend to use the latter.

M.
Mar 31, 2013 at 2:00 AM
Yes, indeed. That certainly did the trick. I'm so happy. And I learned a good thing.