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

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'>
    <RowLimit>1000</RowLimit>
    <Query>
        <And>
            <Eq>
                <FieldRef Name='FSObjType' />
                <Value Type='Text'>0</Value>
            </Eq>
            <Contains>
                <FieldRef Name='FileRef' />
                <Value Type='Text'>/Internal/Bug 594</Value>
            </Contains>
        </And>
    </Query>
</View>

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;
clientContext.Load(tempItems);
clientContext.ExecuteQuery();

//List<ListItem> allItems = new List<ListItem>();
allItems.AddRange(tempItems.ToList());
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

1 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
1  
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

Your Answer

 
discard

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.