I kept on thinking it must be like below. One And and then just add multiple contains.
<listName>Report Names</listName> \
<query><Query><Where><And> \
<Contains><FieldRef Name='Front_Desk_Dept'/><Value Type='Text'>"+myDeptValue+"</Value></Contains> \
<Contains><FieldRef Name='Report_Type'/><Value Type='Text'>"+myReportTypeValue+"</Value></Contains> \
<Contains><FieldRef Name='Region'/><Value Type='Text'>"+myRegionValue+"</Value></Contains> \
</And> \
</Where><OrderBy><FieldRef Name='Title' Ascending='TRUE' /></OrderBy></Query></query> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
<FieldRef Name='Front_Desk_Dept' /> \
<FieldRef Name='Report_Type' /> \
<FieldRef Name='Region' /> \
</ViewFields> \
</viewFields> \
Instead additional And tag must be nested in the layer above. I found below worked.
<listName>Report Names</listName> \
<query><Query><Where><And><And> \
<Contains><FieldRef Name='Front_Desk_Dept'/><Value Type='Text'>"+myDeptValue+"</Value></Contains> \
<Contains><FieldRef Name='Report_Type'/><Value Type='Text'>"+myReportTypeValue+"</Value></Contains> \
</And> \
<Contains><FieldRef Name='Region'/><Value Type='Text'>"+myRegionValue+"</Value></Contains> \
</And> \
</Where><OrderBy><FieldRef Name='Title' Ascending='TRUE' /></OrderBy></Query></query> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
<FieldRef Name='Front_Desk_Dept' /> \
<FieldRef Name='Report_Type' /> \
<FieldRef Name='Region' /> \
</ViewFields> \
</viewFields> \
Must thank the post below for pointed out the syntax
http://aasai-sharepoint.blogspot.hk/2013/02/caml-query-with-multiple-conditions.html
However, for some reason, when I added a 4th condition, it would only work is I further nested an And condition like below.
<listName>Report Names</listName> \
<query><Query><Where><And><And><And> \
<Contains><FieldRef Name='Front_Desk_Dept'/><Value Type='Text'>"+myDeptValue+"</Value></Contains> \
<Contains><FieldRef Name='Report_Type'/><Value Type='Text'>"+myReportTypeValue+"</Value></Contains> \
</And> \
<Contains><FieldRef Name='Region'/><Value Type='Text'>"+myRegionValue+"</Value></Contains> \
</And> \
<Contains><FieldRef Name='Report_Finder_Type'/><Value Type='Text'>"+myReportFinderType+"</Value></Contains> \
</And> \
</Where><OrderBy><FieldRef Name='Title' Ascending='TRUE' /></OrderBy></Query></query> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
<FieldRef Name='Code' /> \
<FieldRef Name='Front_Desk_Dept' /> \
<FieldRef Name='Report_Type' /> \
<FieldRef Name='Region' /> \
<FieldRef Name='Report_Finder_Type' /> \
</ViewFields> \
</viewFields> \
However, for some reason, when I added a 4th condition, it would only work is I further nested an And condition like below.
<listName>Report Names</listName> \
<query><Query><Where><And><And><And> \
<Contains><FieldRef Name='Front_Desk_Dept'/><Value Type='Text'>"+myDeptValue+"</Value></Contains> \
<Contains><FieldRef Name='Report_Type'/><Value Type='Text'>"+myReportTypeValue+"</Value></Contains> \
</And> \
<Contains><FieldRef Name='Region'/><Value Type='Text'>"+myRegionValue+"</Value></Contains> \
</And> \
<Contains><FieldRef Name='Report_Finder_Type'/><Value Type='Text'>"+myReportFinderType+"</Value></Contains> \
</And> \
</Where><OrderBy><FieldRef Name='Title' Ascending='TRUE' /></OrderBy></Query></query> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
<FieldRef Name='Code' /> \
<FieldRef Name='Front_Desk_Dept' /> \
<FieldRef Name='Report_Type' /> \
<FieldRef Name='Region' /> \
<FieldRef Name='Report_Finder_Type' /> \
</ViewFields> \
</viewFields> \
No comments:
Post a Comment