I have the below sample CAML query that I built using the SPCAMLQueryHelper:
<Query>
<Where>
<And>
<Geq>
<FieldRef Name="EndDate" />
<Value IncludeTimeValue="TRUE" Type="DateTime">2014-12-29T00:00:00+02:00</Value>
</Geq>
<Leq>
<FieldRef Name="EventDate" />
<Value IncludeTimeValue="TRUE" Type="DateTime">2015-02-01T23:59:59+02:00</Value>
</Leq>
</And>
</Where>
</Query>
When I test the query in the query helper, I get the expected results (the items that are in the date range).
However, if I query from the front-end as shown below, the results are not filtered, instead, I get back all the items:
var query = new SP.CamlQuery();
query.set_viewXml(queryStringAsAbove);
var lists = web.get_lists();
var list = lists.getByTitle(listName);
context.load(list, 'Include(someFields)');
context.executeQueryAsync(function () {
//Log out all the list items here using .getEnumerator() and .moveNext()
}, function () {
});
What could be the cause of the problem? Why isn't my query being applied when trying to query from the frontend?