-1

In my SharePoint CAML query, when filtering with one input, it is successful. However, when I add in <Or> to include one more input, it failed.

Below are the CAML queries. Is the error due to wrong formatting of Multiple Input?


Single input (pass)

<Where>
    <And>
        <Eq>
            <FieldRef Name="Header1Ref"/><Value Type="Text">H1</Value>
        </Eq>
            <Neq><FieldRef Name ="ContentType"/><Value Type="Text">"Document"</Value></Neq>
    </And>
</Where>

Multiple input (fail)

<Where>
    <And>
        <Eq>
            <Or>
                <FieldRef Name="Header1Ref"/><Value Type="Text">H1</Value>
                <FieldRef Name="Header1Ref"/><Value Type="Text">H2</Value>
            </Or>
        </Eq>
            <Neq><FieldRef Name ="ContentType"/><Value Type="Text">"Document"</Value></Neq>
    </And>
</Where>

Error:

One or more field types are not installed properly. Go to the list settings page to delete these fields. at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView) at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData() at Microsoft.SharePoint.SPListItemCollection.get_Count()

gymcode
  • 4,431
  • 15
  • 72
  • 128
  • 1
    or is parent element not child element . Please use any caml builder like Stramit, U2U caml or etc https://learn.microsoft.com/en-us/sharepoint/dev/schema/or-element-query – Jaynesh Sharma Dec 13 '19 at 07:54

1 Answers1

1

There are Problems with your CAML query. It should be like

<Where>
    <And>
           <Or>
               <Eq> <FieldRef Name="Header1Ref"/><Value Type="Text">H1</Value> </Eq>
               <Eq><FieldRef Name="Header1Ref"/><Value Type="Text">H2</Value> </Eq>
            </Or>
            <Neq><FieldRef Name ="ContentType"/><Value Type="Text">"Document"</Value></Neq>
    </And>
</Where>
Muhammad Murad Haider
  • 1,357
  • 2
  • 18
  • 34