title: Insert a WHERE clause in a CAML query - using SharePoint, SPServices, JavaScript, and jQuery
body: <p>I am trying to insert a WHERE clause into my CAML query to filter a date column for NULL (I want to return all rows for which there is no date in Assign Date the column).</p>
  
  <p>This is for a SharePoint List.  The code is using the SPServices, jQuery, and JavaScript</p>
  
  <p>I am having quite a time pulling this off - I have very little experience doing this type of integration and less still in using CAML. </p>
  
  <p>This is the CAML query segment of the code:</p>
  
  <pre><code>function loadPrioritizedList() {
      $("#tasksUL").empty();
      $().SPServices({
          operation: "GetListItems",    
          webURL: myURL,
          listName: targetListName,
          CAMLViewFields: "&lt;ViewFields&gt;&lt;FieldRef Name='Priority_x0020_Number' /&gt;&lt;FieldRef Name='Edit_x0020_Link' /&gt;&lt;FieldRef Name='Priority' /&gt;&lt;FieldRef Name='Top_x0020_Item_x003f_' /&gt;&lt;FieldRef Name='Purpose' /&gt;&lt;FieldRef Name='Item_x002d_Task_x0020_Order' /&gt;&lt;FieldRef Name='Mode' /&gt;&lt;FieldRef Name='Work_x0020_Status' /&gt;&lt;FieldRef Name='DueDate' /&gt;&lt;FieldRef Name='Task_x0020_Type' /&gt;&lt;FieldRef Name='DAK_x0020_Date' /&gt;&lt;FieldRef Name='DAK_x0020_No' /&gt;&lt;FieldRef Name='AssignedTo' /&gt;&lt;FieldRef Name='Money_x0020_Estimate' /&gt;&lt;FieldRef Name='ItemStatus' /&gt;&lt;FieldRef Name='Assign_x0020_Date' /&gt;&lt;/ViewFields&gt;",
          CAMLQuery: '&lt;Query&gt;' +
          '&lt;OrderBy&gt;' +
          '&lt;FieldRef Name="Priority_x0020_Number" /&gt;' +
          '&lt;/OrderBy&gt;' +
          '&lt;/Query&gt;', 
          CAMLRowLimit: listrowlimit,  
          completefunc: function (xData, Status) {
              $(xData.responseXML).SPFilterNode("z:row").each(function() {
                  var tdHtml = "&lt;tr class='sortable_row' id=" + $(this).attr("ows_ID") + "&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:60px;\"&gt;" + PriorityFormat($(this).attr("ows_Priority_x0020_Number"));  + "&lt;/td&gt;";
                  tdHtml = tdHtml + '&lt;td style=\"width:49px;\"&gt;&lt;a href=\"'+($(this).attr("ows_Edit_x0020_Link")).split(", ")[1] + '\"&gt;' + ($(this).attr("ows_Edit_x0020_Link")).split(", ")[1] + '&lt;/a&gt;&lt;/td&gt;';
                  tdHtml = tdHtml + "&lt;td style=\"width:83px;\"&gt;" + $(this).attr("ows_Priority") + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:63px;\"&gt;" + TopItem($(this).attr("ows_Top_x0020_Item_x003f_")) + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:300px;\"&gt;" + StringChk($(this).attr("ows_Purpose")) + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:125px;\"&gt;" + StringChk($(this).attr("ows_Item_x002d_Task_x0020_Order")) + "&lt;/td&gt;";                     
                  tdHtml = tdHtml + "&lt;td style=\"width:40px;\"&gt;" + StringChk($(this).attr("ows_Mode")) + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:75px;\"&gt;" + StringChk($(this).attr("ows_Task_x0020_Type")) + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:150px;\"&gt;" + StringChk($(this).attr("ows_Work_x0020_Status")) + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:100px;\"&gt;" + FormatDate($(this).attr("ows_DueDate")) + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:100px;\"&gt;" + FormatDate($(this).attr("ows_DAK_x0020_Date")) + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:100px;\"&gt;" + StringChk($(this).attr("ows_DAK_x0020_No")) + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:300px;\"&gt;" + StringChk($(this).attr("ows_AssignedTo")) + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:125px;\"&gt;" + $(this).attr("ows_Money_x0020_Estimate") + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:75px;\"&gt;" + StringChk($(this).attr("ows_ItemStatus")) + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;td style=\"width:100px;\"&gt;" + FormatDate($(this).attr("ows_Assign_x0020_Date")) + "&lt;/td&gt;";
                  tdHtml = tdHtml + "&lt;/tr&gt;";
                  $("#tasksUL").append(tdHtml);
              });
          }
      });
  </code></pre>
  
  <p>Any help would be gratefully welcomed, and I thank you in advance.</p>
  
  <p>UPDATE:
  The latest incarnation of the code is below.  I have added the "WHERE" clause as: </p>
  
  <pre><code>"&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=Assign_x0020_Date' /&gt;&lt;Value Type='Date and Time'&gt;IsNull&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;" +
  </code></pre>
  
  <p>But it still returns no results.  I'm not sure at this point what I'm missing here.</p>
  
  <p>The query with the above addition looks like this:</p>
  
  <pre><code>function loadPrioritizedList() {
          $("#tasksUL").empty();
          $().SPServices({
              operation: "GetListItems",    
              webURL: myURL,
              listName: targetListName,
              CAMLViewFields: "&lt;ViewFields&gt;&lt;FieldRef Name='Priority_x0020_Number' /&gt;&lt;FieldRef Name='Edit_x0020_Link' /&gt;&lt;FieldRef Name='Priority' /&gt;&lt;FieldRef Name='Top_x0020_Item_x003f_' /&gt;&lt;FieldRef Name='Purpose' /&gt;&lt;FieldRef Name='Item_x002d_Task_x0020_Order' /&gt;&lt;FieldRef Name='Mode' /&gt;&lt;FieldRef Name='Work_x0020_Status' /&gt;&lt;FieldRef Name='DueDate' /&gt;&lt;FieldRef Name='Task_x0020_Type' /&gt;&lt;FieldRef Name='DAK_x0020_Date' /&gt;&lt;FieldRef Name='DAK_x0020_No' /&gt;&lt;FieldRef Name='AssignedTo' /&gt;&lt;FieldRef Name='Money_x0020_Estimate' /&gt;&lt;FieldRef Name='ItemStatus' /&gt;&lt;FieldRef Name='Assign_x0020_Date' /&gt;&lt;/ViewFields&gt;",
              CAMLQuery: '&lt;Query&gt;' +
      "&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='Assign_x0020_Date' /&gt;&lt;Value Type='Date and Time'&gt;IsNull&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;" +
              '&lt;OrderBy&gt;' +
              '&lt;FieldRef Name="Priority_x0020_Number" /&gt;' +
              '&lt;/OrderBy&gt;' +
              '&lt;/Query&gt;', 
  </code></pre>