CAMLQueryOptions in SPServices

Oct 29, 2009 at 9:31 AM

Hi

My GetListItems web service call ignores CAMLQueryOptions parameter.

First call:

 

$().SPServices({
operation: "GetListItems",
listName: "Test Library",
CAMLQuery: "<Query><Where><And><Eq><FieldRef Name='fieldName' /><Value Type='Text'>Example</Value></Eq><Eq><FieldRef Name='Status' /><Value Type='Text'>private </Value></Eq></And></Where></Query>",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
CAMLRowLimit: "<RowLimit>0</RowLimit>",
CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='Recursive' /></QueryOptions>",
completefunc: function(xData, Status) {
$(xData.responseXML).find("z\\:row").each(function() {
...
});
});


Second call:

$().SPServices({
operation: "GetListItems",
listName: "Test Library",
CAMLQuery: "<Query><Where><And><Eq><FieldRef Name='fieldName' /><Value Type='Text'>Example</Value></Eq><Eq><FieldRef Name='Status' /><Value Type='Text'>private </Value></Eq></And></Where></Query>",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
CAMLRowLimit: "<RowLimit>0</RowLimit>",
completefunc: function(xData, Status) {
$(xData.responseXML).find("z\\:row").each(function() {
...
});
});

 

Structure Library "Test Library":

rootFolder

  • documentA (fieldName = Example; Status = private)
  • documentB (fieldName = Example; Status = private)
  • documentC (fieldName = Example; Status = public)
  • subFolder1
  • documentD (fieldName = Example; Status = private)

Both GetListItems return only documents in the root folder (documentA and documentB), omitting the subfolders.

 

Thanks

J.

Coordinator
Oct 30, 2009 at 2:42 AM

J.:

I'll definitely take a look at this over the next few days.  Thanks for letting me know.  Watch for a new release or follow @jQSPWS for updates.

M.

Oct 30, 2009 at 9:20 AM

Thanks from reply M.

I used both versions (jquery.SPServices-0.4.1.js and jquery.SPServices-0.3.1.js) and I still have the same problem.

J.

Coordinator
Oct 30, 2009 at 1:27 PM

This is a headscratcher.  I've spent a little time debugging this, and I'm definitely passing the QueryOptions into the Web Service.  I can't spot any typos or spelling mistakes, either.  I'll keep looking at it, but it does indeed seem to be a bug.

M.

Coordinator
Oct 30, 2009 at 1:30 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Nov 3, 2009 at 1:55 PM

Hi

I found the bug. I created my webservice calls inspired by your metods in jquery.SPServices.
The bug is in CALMRowLimit parameter. It can't be "<RowLimit>0</RowLimit>" because in GetListItems webservice this parameter type is string, not XmlNode, so
you can't pack it in xml <RowLimit></RowLimit> tags
case "GetListItems":
   SOAPEnvelope.payload += wrapNode("listName", opt.listName);
   SOAPEnvelope.payload += wrapNode("viewFields", opt.CAMLViewFields);
   SOAPEnvelope.payload += wrapNode("query", opt.CAMLQuery);
   SOAPEnvelope.payload += wrapNode("rowLimit", opt.CAMLRowLimit);
   SOAPEnvelope.payload += wrapNode("queryOptions", opt.CAMLQueryOptions);
break;
Is work when I change CALMRowLimit in "0".
All call $().SPServices({ ... }) in jquery.SPServices-0.4.1.js have this bug.
J.
Coordinator
Nov 3, 2009 at 2:31 PM
Edited Nov 3, 2009 at 2:33 PM

You're right! Great work.  I always love it when someone else does my debugging for me.

I'll have this fix in the SPServices functions the v0.5.0 release, though I don't think that there are any implications currrently.

M.