SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can someone tell me why the following CAML query is not filtering results? It's returning files that do not contain "/Internal/Bug 594" in their FileRef value. Thanks.

<View Scope='Recursive'>
                <FieldRef Name='FSObjType' />
                <Value Type='Text'>0</Value>
                <FieldRef Name='FileRef' />
                <Value Type='Text'>/Internal/Bug 594</Value>

And here's the code i'm using to execute this query:

CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = [the query you see above];

//IEnumerator<ClientOM.List> LibsIterate = null;
ListItemCollection tempItems = LibsIterate.Current.GetItems(camlQuery);

//ClientOM.ClientContext clientContext = null;

//List<ListItem> allItems = new List<ListItem>();
share|improve this question
Try converting <Value Type='Text'> to <Value Type='URL'> – Arsalan Adam Khatri Dec 5 '12 at 14:24
Also instead of FileRef, try using ServerUrl field with <Value Type='Text'> – Arsalan Adam Khatri Dec 5 '12 at 14:40

Well, as you already guessed if the CAML query is not syntactically correct it will just run and return everything without applying any filters or ordering.

You don't get any exceptions and this is pretty counter-intuitive.

share|improve this answer

I think the problem is that the value of the FileRef field contains a space. Try replacing the space with %20 and see if it works.

share|improve this answer
sigh It's missing the <Where></Where> clause. Thanks for the suggestions guys. I guess it ignores that whole <And> clause, and just runs it as <Query></Query>. – Victor Dec 5 '12 at 19:12
Please set that as an answer. And yes, when there is an issue with the query SP just returns all items. – Robert Kaucher Jun 30 '13 at 1:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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