1

I have CAML queries performed against SharePoint Online lists through SPServices that have worked beautifully for 5 years. Sometime in the last couple of weeks they started returning incorrect results. The problems all seem to be oriented around the "EndOfLife" text field which always contains a "1" or a "0" (without the quotes).

<Where>
  <Eq>
    <FieldRef Name='EndOfLife'></FieldRef>
    <Value Type='Text'>1</Value>
  </Eq>
</Where>

Executed through SPServices in the browser, this query against a particular list returns 10 results. The same query against the same list executed through U2U CAML Query Builder returns over 900 results.

Executed against a different list in another site collection, that query returns 3 results through SPServices in the browser and 2000 results through U2U CAML Query Builder.

There are no changes on my end that correlate with the timing of these problems.

Any idea why these queries executed through SPServices in the browser would suddenly be returning incorrect results?

  • Can you try converting it rest api instead? – Billy Aug 27 at 15:38
  • Yes, but that would mean converting a massive amount of code, and it doesn't answer the question. – Skip Aug 27 at 15:46
  • I can only think of the difference is permission. We're you using same accounts to query? – Billy Aug 27 at 16:47
  • Yes, definitely using the same account. But I appreciate your input, for the record. – Skip Aug 27 at 17:13
1

Most likely, you just need to specify RowLimit (CAMLRowLimit) parameter for your query: https://sympmarc.com/2011/07/26/tip-for-using-spservices-with-getlistitems/

Otherwise, the CAML query is executed on a default view of your list.

  • @Skip, is it possible that the default view has been changed recently? – Abhishek Aug 28 at 8:04
  • Thank you very much for this answer and comment. I'm very glad to have this information. However, it did not solve the problem. – Skip Aug 28 at 15:45
0

How many items in the list view?

Make sure the number of items doesn’t exceed list view threshold 5000. If so, try to index the column in list.

Reference: CAML Query - Going around the 5000 List Item Threshold

  • There are only 1k-3k items in either of the lists I mentioned in the original post. – Skip Aug 28 at 15:46
0

Currently, the "EndOfLife" columns are of type Number instead of Single Line of Text. I adjusted the queries to reflect this and the queries now return correct results.

<Where>
  <Eq>
    <FieldRef Name='EndOfLife'></FieldRef>
    <Value Type='Number'>1</Value>
  </Eq>
</Where>

However, this in itself still doesn't explain why the original queries suddenly stopped working. Moreover, I'm almost certain that the "EndOfLife" column was previously a text column; I specifically recall regretting not making it a number column. As previously mentioned, there were no changes on my end that correlate to the breakage. Furthermore, I'm the only person who can access the lists and their settings as well as the codebase, so it's not possible that something happened on my organization's side without my knowledge.

As crazy as it sounds, Microsoft somehow converting the column types from text to number is the only explanation I can think of that fits all of the above facts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.