Quantcast
Viewing all articles
Browse latest Browse all 6517

New Post: Can GetListItems be filtered by item ID?

myahia wrote:
Thanks, Marc.

What's the syntax? I'm new to CAMLQuery.

I looked at the documentation. It doesn't list CAMLQuery. Is this it?
<Query>
   <Where>
      <Lt>
         <FieldRef Name="ID" />
         <Value Type="Counter">3</Value>
      </Lt>
   </Where>
</Query>
myahia wrote:
   var htmlTable = '<table>';
$().SPServices({
   operation: "GetListItems",
   async: false,
   listName: "Attributes",
   CAMLQuery: "<Eq><FieldRef Name='ID'></FieldRef><Value Type='Integer'>758</Value></Eq>",
   CAMLViewFields: "<ViewFields>" +
               "<FieldRef Name='Title' ></FieldRef>" +
               "<FieldRef Name='Values' ></FieldRef>" +
               "<FieldRef Name='ID' ></FieldRef>" +
           "</ViewFields>",
   
   completefunc: function (xData, Status) {
       $(xData.responseXML).SPFilterNode('z:row').each(function() {
           
           htmlTable += "<tr>" +
               "<td>" + $(this).attr("ows_Title") + "</td>" +
               "<td>" + $(this).attr("ows_Values") + "</td>" +
               "<td>" + $(this).attr("ows_ID") + "</td>" +
           "</tr>";
       })
       htmlTable += "</table>";
   }
});
Your CAMLQuery is different than the original one you posted. Wrap in with <Query> and <Where>. I'd also like to see you change the value type to Counter, but Integer does seem to work FWIW.

Cheers,
Matthew

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>