I am going to implement a search query. I have 2 inputs user can give value or leave as empty. If user leave both input as empty and Search,,all items must populated. here I have static SP CAML query string. With 2 variables. but any variable can empty. When that variable empty I want to ignore that where part and get values. How can I do it?
<Query>
<Where>
<And>
<Eq>
<FieldRef Name="Title" />
<Value Type="Text">var1</Value>
</Eq>
<Eq>
<FieldRef Name="Subchannel" />
<Value Type="Text">var2</Value>
</Eq>
</And>
</Where>
</Query>
When var1
is empty I want to ignore that where condition. If both var1
and var2
is empty I want to get all items from list.