I have written a CAML query using <Or>
with <Contains>
.
the query looks similar to below:
<Where>
<Or>
<Or>
<Contains><FieldRef Name="Field1" /><Value Type="Text">`
+SearchTerms +`</Value>
</Contains>
<Contains><FieldRef Name="Field2" /><Value Type="Text">`
+SearchTerms +`</Value>
</Contains>
</Or>
<Or>
<Contains><FieldRef Name="field3" /><Value Type="Lookup">`
+SearchTerms +`</Value>
</Contains>
<Contains><FieldRef Name="field4" /><Value Type="Lookup">`
+SearchTerms +`</Value>
</Contains>
</Or>
</Or>
</Where>
Basically what I want to do is return all rows that contain search terms in one of those four fields(field1,field2,field3,field4).
for example if I SearchTerms is 'abc' then all rows where any of the fields contain abc should be returned.
This works most of the time. It fails when there is an empty in field3 or field4.
Basically, if field1 and/or two meet the criteria, but field3 or field4 is empty it won't return that row. It still returns rows if there are multiple rows. I've tried rearranging things and it doesn't seem to help.
I'm currently developing this in spfx. When I check the json I am finding that the rows are not returned there. I belive it is definately my Caml query.
Any help would be greatly appreciated.