In this scenario we will describe how to add a filter to a report that will enable users to filter the report from the report user interface.
Note: This scenario is a follow on to the Add Column to List and Update Report scenario. It assumes you have completed the steps in that scenario and have added the Country column to the report you created in the BrightWork Reporter Library.
We recommend that you require reports to be checked out before they can be edited. This means that any changes you make to a report will not be visible to other users until the report is checked in.
Adding filters to reports requires a working knowledge of CAML.
This adds the filter user interface to the report.
You must update the CAML in the list query templates that returns data from the lists you updated. As we have only added the Country column to the Project Issues list, this is the only list query template we will update.
Note: It is important you do this before working on the CAML, as selecting a new context resets the CAML in the displayed List Query Template.
Update the CAML to filter against the column you added.
Change:
<Where><Eq><FieldRef Name="CompletedFlag" /><Value Type="Boolean">0</Value></Eq></Where>
to
<Where><And><Eq><FieldRef Name="CompletedFlag" /><Value Type="Boolean">0</Value></Eq><Eq><FieldRef Name="Country" /><Value Type="Text">[Country]</Value></Eq></And></Where>
Note: See Working with Query CAML for more information on CAML.
Note: If you return to the report and apply the filter, you may notice that there are items in the report from other lists. This is because the other lists do not have the Country column and their associated List Query Templates have not been updated. For the filter to work against the other lists you could add the column to these lists and update the CAML in the associated List Query Template.
Alternatively, you could create a new List of Lists and Edit the List Inclusion settings - this is what we will do next.