Rules
Rules are used to filter report results. They allow the same report to be filtered depending on the user that is running it.
The following steps need to be performed in order to use rules:
-
Create the rule
Use the Configure | Rules menu and then the Add button to specify the rule name
-
Link the rule to a report
On the report definition page, select the Uses Rules option
In the SQL source section, use the special, hard coded placeholder #rules# where you want the rule values to go e.g
SELECT * from transactions
where #rules#
On the reports configuration page, find the report and use the More | Rules menu to specify which column the rule values will apply to
- Assign rule values to users or user groups
Use the Configure | Rule Values menu to assign rule values to users or user groups. Select the user or user group and rule name, and specify the rule values that will apply to that user or user group. If you want the user or user group to have multiple rule values, add each value separately. i.e enter the first value, then click on Add, then enter the next value etc.
Example:
- You have a table named "employees" with the a column named "region"
- Create a rule named "GeoArea"
- Set up a report that selects rows from the employees table and link it to the rule named "GeoArea" on the column "employees.region"
- Link the user to the rule "GeoArea" for values NORTH and EAST
When the user runs the report, he will extract only the rows where the "region" column has the values NORTH or EAST (i.e. the SQL query will be modified on the fly before execution by adding AND employees.region IN ('NORTH','EAST')
to the WHERE clause).
Note:
- If a report is linked to a rule but the user who runs the report has not been set up for that rule, the report execution will not be performed and an error message will be displayed.
- If the report uses multiple rules, each user that needs to execute it must have values set for all the rules that the report uses.
- If the report uses parameters, the placeholder #rules# shouldn't be used for any parameter as it will conflict with the special placeholder for rules.
- If you don't want results filtered for a given user e.g. an administrator, manager etc, define a rule value for this user where the rule value is ALL_ITEMS.