CAMLQuery not filtering

May 3, 2011 at 10:36 PM

Has anyone had any issues with the CAMLQuery parameter not filtering at all? I have set up a list called maps, with 2 fields (Page [text] and Book [choice]).  I am able to use SPServices to bring back the data from the list, however, when I try to use the CAMLQuery parameter to filter, I continue to get all results back.  Maybe I am not seeing the mistake.  but my code is below.

I have tried to hard code a value into the CAMLQuery to no avail, and have also tried this on a brand new list with the same data.  I have also changed the  value type to see if that would make a different, but still continue to get back too many results.. any help would be appreciated

<script type="text/javascript">

 


var bookName = getParameterByName('bookName');
var preFix = "";
var folderName="";
var dfsPath = "myDFSPath"
var pageLink = "";

switch(bookName)
{
case 'Alabama-Florida':
  preFix='VAMO';
  folderName='Alabama_Florida';
  break;
case 'Carthage':
  preFix='VTCA';
  folderName='Carthage';
  break;
case 'Lafayette':
  preFix ='VLLA';
  folderName='Lafayette';
  break;
default:
  alert("don't know what book");
}

//alert(preFix);
//alert (folderName);
//alert(bookName);

 

var camlQuery = "<Query><Where><Eq><FieldRef Name='Book'/><Value Type='Choice'>"+ bookName +"</Value></Eq></Where></Query>"

//alert(camlQuery );

 


//These are global variables that will be used by the query to the SharePoint list

  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Maps",
    camlQuery: camlQuery,
    completefunc: function (xData, Status) {
      alert(xData.responseXML.xml);
      $(xData.responseXML).find("[nodeName='z:row']").each(function() {
      var pageLink = dfsPath + folderName + '/' + preFix +  $(this).attr("ows_Title") + '.pdf';
      //alert(pageLink);
       var newTr = '<tr><td name="pageTD"><a href="' + pageLink  + '">Sheet ' + $(this).attr("ows_Title") + '</a></td></tr>';
      $('#mapsTable').append(newTr);       });
    }
  });

 


// function to return a query string paramater by the name of the parameter.

function getParameterByName(name) {

var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);

return match ? decodeURIComponent(match[1].replace(/\+/g, ' ')) : null;

}


</script>

 

 

 

Coordinator
May 4, 2011 at 1:53 AM
Edited May 4, 2011 at 1:53 AM
miriv365:
 
It's usually the little things. ;+) It's CAMLQuery, as opposed to camlQuery. Unfortunately, case matters, so jQuery is ignoring the camlQuery option, as it has no use for it.
M.
May 14, 2011 at 4:06 AM

Thanks....that was it....