I'm wondering if it is possible to use GetListItems to query a list using a specific value and to return only the line(s) that match that query ?
At the moment I can use GetListItems to retrieve all the items in a list, or all the items in a specific view but I can't filter any further.
I appreciate that I can just perform the query on the set of items returned but was wondering if its possible (and perhaps faster) to have sharepoint perform the query for me.
In the yoursharepoint/_vti_bin/Lists.asmx?op=GetListItems page I see,
<query>
<xsd:schema>schema</xsd:schema>xml</query>
<viewFields>
<xsd:schema>schema</xsd:schema>xml</viewFields>
<rowLimit>string</rowLimit>
<queryOptions>
<xsd:schema>schema</xsd:schema>xml</queryOptions>
But don't know how/if these parameters can be used.
Yes you can call the GetListItems operation and pass the CAMLQuery parameter. Asume the following html
<div id='result'></div>
I'm looking for all listitems matching the term 'Bob Tester' in the title column using the following SPServices call.
$().SPServices({
operation: "GetListItems",
async: false,
listName: "MyCustomList",
CAMLQuery: "<FieldRef Name='Title'></FieldRef><Value Type='Text'>Bob Tester</Value>",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var foundItem = "<div>" + $(this).attr("ows_Title") + " matches</div>";
$("#result").append(foundItem);
});
}
});