1
votes

I've poured through various articles but haven't found an answer to my exact scenario. I've a SharePoint 2010 list with some Query Parameters for filter purposes. My CAML Query works well for filtering except in one circumstance, I'd like a General Display All criteria in my query for when the listview is first hit (i.e. my client will actively be able to see/page/sort the data without first having to search the list). If I was just filtering the list fields I'd be set, but since I'm referencing Query Parameters in my CAML I'm receiving SOAP errors in SharePoint Designer. The SQL equivalent would be: Where (@Parameter1 is null and @Parameter2 is null and @Parameter3 is null...)

I've tried this structure:

    <Or Group="true">
       <And>
         <And>
           <IsNull>
           <FieldRef Name ="Title"/>
           <Value Type="Text">{RollNum}</Value>
           </IsNull>
        <Gt>
          <FieldRef Name="ID"/>                     
          <Value Type="Counter">
         <IfEqual>
          <Expr1><![CDATA[{Param1}]]></Expr1>   
          <Expr2/>
          <Then>0</Then>                    
          <Else>2147483647</Else>
        </IfEqual>
        </Value>
      </Gt>
    </And>
   <IsNull>
      <FieldRef Name ="RefNumber"/>
      <Value Type="Text">{RefNum}</Value>
      </IsNull>
    </And>
</Or>...the rest of the query, which works fine.

I have a feeling my structure is incorrect.

Thanks in advance, Brian H.

2

2 Answers

1
votes

You can use this syntax to determine if a field is null:

<Where><IsNull><FieldRef Name='YourFieldName' /></IsNull></Where>

You have an extra Value element within IsNull that you should remove.

0
votes

I decided to use an HTML Form Web Part to achieve my goal (instead of a content editor). The HTML form web part keeps all filter values entered into any boxes, and can be wired up to filter my list using parameters and a custom caml query.