Domanda

I'm trying to query all items in a meeting workspace list. I'm trying a query I think should work, but still only returns items specific to the instanceID. Is there a different flavor for client side caml?

Here's my JavaScript:

var camlQuery = new SP.CamlQuery();
var viewXML = "<View><Query><Where><IsNotNull><FieldRef Name=\'Registrant\' /></IsNotNull></Where></Query><QueryOptions><MeetingInstanceID>-1</MeetingInstanceID></QueryOptions></View>";
camlQuery.set_viewXml(viewXML);

Thanks for any insight.

È stato utile?

Soluzione

It turns out the QueryOptions element is not used in the CamlQuery object in the client object model. I eventually turned to SPServices. Here is the statement that did the trick for me:

$().SPServices({
  operation: "GetListItems",
  async: false,
  listName: "Registrants",
  CAMLViewFields: "<ViewFields><FieldRef Name=\'Registrant\' /></ViewFields>",
  CAMLQuery: "<Query><Where><Eq><FieldRef Name=\'Registrant\' LookupId=\'TRUE\'/><Value Type=\'Lookup\'>" + cUserId +"</Value></Eq></Where></Query>",
  CAMLQueryOptions: "<QueryOptions><MeetingInstanceID>-1</MeetingInstanceID></QueryOptions>",
  completefunc: function(xData,Status){
    regListCount=$(xData.responseXML).SPFilterNode("rs:data").attr("ItemCount");
    regInstanceId=$(xData.responseXML).SPFilterNode("z:row").attr("ows_InstanceID");
    regItemId=parseInt($(xData.responseXML).SPFilterNode("z:row").attr("ows_ID"));
  }
});

Altri suggerimenti

I don't think the <QueryOptions> element is supported in the Client Object Model.

For your requirement, if you want to get all the items in a list, you can use the follwing code:

var camlQuery = new SP.CamlQuery.CreateAllItemsQuery();

You don't need to specify the viewXml explicitly in this case.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top