0

I've got a mad issue. I'm doing a caml query on a couple of lists. When I make the query with querying the contenttype I get 2 results. If I remove the contenttype from the query, it returns no results. How can that? Please see both queries:

with contenttype:

<Where>
    <And>
        <And>
            <Eq>
                <FieldRef Name='Invalid' />
                <Value Type='Boolean'>
                    <![CDATA[0]]>
                </Value>
            </Eq>
            <And>
                <Eq>
                    <FieldRef Name='SupplierPGProduct' />
                    <Value Type='Text'>
                        <![CDATA[414 - Organic Pigments - Toyo Ink]]>
                    </Value>
                </Eq>
                <Or>
                    <Contains>
                        <FieldRef Name='Title' />
                        <Value Type='Text'>
                            <![CDATA[fiber]]>
                        </Value>
                    </Contains>
                    <Contains>
                        <FieldRef Name='LinkFilename' />
                        <Value Type='Computed'>
                            <![CDATA[fiber]]>
                        </Value>
                    </Contains>
                </Or>
            </And>
        </And>
        <Eq>
            <FieldRef Name='ContentType' />
            <Value Type='Computed'>
                <![CDATA[Brochure]]>
            </Value>
        </Eq>
    </And>
</Where>

Result: 2 items

without contenttype:

<Where>
    <And>
        <And>
            <Eq>
                <FieldRef Name='Invalid' />
                <Value Type='Boolean'>
                    <![CDATA[0]]>
                </Value>
            </Eq>
            <And>
                <Eq>
                    <FieldRef Name='SupplierPGProduct' />
                    <Value Type='Text'>
                        <![CDATA[414 - Organic Pigments - Toyo Ink]]>
                    </Value>
                </Eq>
                <Contains>
                    <FieldRef Name='Title' />
                    <Value Type='Text'>
                        <![CDATA[fiber]]>
                    </Value>
                </Contains>
            </And>
        </And>
        <Contains>
            <FieldRef Name='LinkFilename' />
            <Value Type='Computed'>
                <![CDATA[fiber]]>
            </Value>
        </Contains>
    </And>
</Where>

Result: 0 items

Anybody an idea or a hint for me?

3

In the second query the condition Linkfilename contains fiber is implemented differently. I tried to break down each query

Query 1:

(
  ( Invalid="0" AND 
         ( SupplierPGProduct="Organic Pigments - Toyo Ink" AND 
              ( Title="Fiber" OR LinkFileName contains "Fiber" ) 
         ) 
   ) AND 
   ContentType="Brochure"
)

Query 2:

( 
   ( Invalid = "0" AND 
       ( SuplierPGProduct="Oranic Pigment - Tokyo Ink" AND Title contains "Fiber" ) 
   ) AND 
   LinkFileName contains "fiber" 
)

If you want to remove contentType condition from the first query it would look like below

<Where>
        <And>
            <Eq>
                <FieldRef Name='Invalid' />
                <Value Type='Boolean'>
                    <![CDATA[0]]>
                </Value>
            </Eq>
            <And>
                <Eq>
                    <FieldRef Name='SupplierPGProduct' />
                    <Value Type='Text'>
                        <![CDATA[414 - Organic Pigments - Toyo Ink]]>
                    </Value>
                </Eq>
                <Or>
                    <Contains>
                        <FieldRef Name='Title' />
                        <Value Type='Text'>
                            <![CDATA[fiber]]>
                        </Value>
                    </Contains>
                    <Contains>
                        <FieldRef Name='LinkFilename' />
                        <Value Type='Computed'>
                            <![CDATA[fiber]]>
                        </Value>
                    </Contains>
                </Or>
            </And>
        </And>
</Where>

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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