3

I'm fighting with the Caml Query which returns zero items:

<View>
    <Query>
        <Where>
            <And>
                <Eq>
                    <FieldRef Name="Dokumenttyp"/>
                    <Value Type="Text">Fahrtspesen</Value>
                </Eq>
                <And>
                    <Geq>
                        <FieldRef Name="ExportiertAm"/>
                        <Value Type="DateTime">2017-08-12</Value>
                    </Geq>
                    <Lt>
                        <FieldRef Name="ExportiertAm"/>
                        <Value Type="DateTime">2017-08-13</Value>
                    </Lt>
                </And>
            </And>
        </Where>
    </Query>
</View>

What I do not understand, the following two return something. The first returns many items (one of these is the one with ID 290) and the second one returns two items (the 290 and the 291).

<View>
    <Query>
        <Where>
            <Eq>
                <FieldRef Name="Dokumenttyp"/>
                <Value Type="Text">Fahrtspesen</Value>
            </Eq>
        </Where>
    </Query>
</View>

<View>
    <Query>
        <Where>
            <And>
                <Geq>
                    <FieldRef Name="ExportiertAm"/>
                    <Value Type="DateTime">2017-08-12</Value>
                </Geq>
                <Lt>
                    <FieldRef Name="ExportiertAm"/>
                    <Value Type="DateTime">2017-08-13</Value>
                </Lt>
            </And>
        </Where>
    </Query>
</View>

Based on the results of the latter two, shouldn't the first one return something?

  • Is there any error dialog show up when you use the query? – Anh Vo Aug 29 '17 at 6:59
  • No errors, simply zero results. – Emaborsa Aug 29 '17 at 7:28
  • I don't see any error in your query. Your combined query should return one item that has ID 290. – Rohit Waghela Aug 29 '17 at 9:51
  • please share your code that you are using to fetch the data. – Rohit Waghela Aug 29 '17 at 9:53
1

While CAML works it's logic '2 at a time', I've found that having an AND/OR group at the end doesn't work sometimes, even though it logically should. Since you've got all ANDs, maybe try a bit of rearranging. It makes no sense, I know. Also, another thing I've tried is to get rid of your code completely and retype it. There could be an 'invisible' character or extra space that is causing a problem without reporting an error.

         <And>
            <And>
                <Geq>
                    <FieldRef Name="ExportiertAm"/>
                    <Value Type="DateTime">2017-08-12</Value>
                </Geq>
                <Lt>
                    <FieldRef Name="ExportiertAm"/>
                    <Value Type="DateTime">2017-08-13</Value>
                </Lt>
            </And>
            <Eq>
                <FieldRef Name="Dokumenttyp"/>
                <Value Type="Text">Fahrtspesen</Value>
            </Eq>
        </And>
0

You can use U2U caml query builder for framing the queryenter image description here

  • This is not an answer to my question. – Emaborsa Aug 30 '17 at 6:02

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.