I have a JavaScript piece of code that I use to retrieve list item from SharePoint by selected options from drop-down list. Depending the selection it would assign a value to a CAMLQuery variable.

Option 1 (filters by Office):

CAMLQuery = "<Query><Where><Eq><FieldRef Name='Regional_x0020_Office' /><Value Type='Text'>" + regionalOffice + "</Value></Eq></Where></Query>"

Option 2 (filters by Year):

CAMLQuery = "<Query><Where><Eq><FieldRef Name='Fiscal_x0020_Year' /><Value Type='Text'>" + fiscalYear + "</Value></Eq></Where></Query>"

Option 3 (All items):

CAMLQuery = "<View><Query><OrderBy><FieldRef Name='Fiscal_x0020_Year' Ascending='TRUE' /></OrderBy></Query></View>"

Everything works perfectly, except Option 3, which is the one I would like to use to show all Items. What am I missing here? Thanks!

  • 1
    I suspect because you've wrapped the Query with a View node in option 3, it isn't present in the other 2 working examples. Jul 23, 2014 at 15:33

3 Answers 3


Don't add View Tag, reform the query as follows:

CAMLQuery = "<Query><OrderBy><FieldRef Name='Fiscal_x0020_Year' Ascending='TRUE' /></OrderBy></Query>"

Try adding a null check:

CAMLQuery = "<Query><Where><IsNotNull><FieldRef Name='Fiscal_x0020_Year' /></IsNotNull></Where><OrderBy><FieldRef Name='Fiscal_x0020_Year' Ascending='True' /></OrderBy></Query>"
  • Thanks, but I forgot to mentioned that I've done that already and no luck.
    – cubanGuy
    Jul 23, 2014 at 14:23
  • OK. I have edited my answer. Try adding a null check in there Jul 23, 2014 at 14:27

Perhaps its the default RowLimit that is causing you to not retrieve all results? A RowLimit of 0 will return all results. For example:

"<View><Query><OrderBy><FieldRef Name=\"Fiscal_x0020_Year\" Ascending=\"TRUE\"></FieldRef></OrderBy></Query><RowLimit>0</RowLimit></View>"

Also, the following information from http://msdn.microsoft.com/en-us/library/office/ms428643(v=office.14).aspx is worth noting regarding RowLimit:

If Paged is not TRUE and the row limit is exceeded, the server renders a RowLimitExceeded element in the view if this element is specified. Otherwise, the default behavior is to give no indication to the user that the row limit has been exceeded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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