The following example shows you how to set up a record-level security policy for a report:
<install_root>\Demo\Reports\SampleReports, then open the sample report EmployeeInformation.cls.
to the right of the Record Security property entry to open the Record Level Security Information dialog. See the dialog.
Since the record-level security policies are file-based, you can just create a new text file, add the security settings, and then link the file to your report. Below are steps detailing how to import the security information from a text file.
Notes:
For example, both Customer ID >= 10 and Customer Name = 'Absolute Java' together will cause JReport Designer to retrieve records where customer ID is larger than or equal to 10 and the record with customer name equal to Absolute Java.
If you want to use logical AND for the relationship between each condition expression, use a formula that returns a Boolean value to filter the records. To specify the formula name for a report, in the Properties panel, select or type the formula name in the Function property entry.
For example, if user1 should only see records which satisfy the condition State = 'CO' and Customer ID >= 10, the formula should be:
if ( @State == 'CO' && @"Customer ID">= 10 ) return "user1"
If both the Record Level Security Information dialog and a formula have been used to control the security information, both will take effect. The relationship between them is logical OR.
| User | Role | Column | Operator | Value | Title | |
|---|---|---|---|---|---|---|
| admin | admin | |||||
| user1 | Customer ID | >= | 10 | user1@yoursite.com | Mr. | |
| user1 | Customer Name | = | 'Absolute Java' | |||
| user2 | Customer Name | IN | ('Absolute Java','American Coffee Inc.') | user2@yoursite.com | Miss | |
| user3 | Phone | IN | ('(212) 555-3462','(317) 555-1274') | user3@yoursite.com | Mrs. |