Chapter 8. User Variables

8. User Variables

User variables are designed to adapt a report to the needs of the user executing it. By applying user variables, the same report holds a different base data entirety for different users.

We would like to explain user variables based on an example. The employees of an enterprise are distributed to two locations. They shall be given access to the sales figures of the enterprise, however, only to the data relevant for their respective location. You can model this requirement by establishing two separate reports (which are almost identical), and by granting the employees of location A access to the one report and the employees of location B to the other report. But you can also design a single report, and by applying user variables restrict the base data entirety per each executing user. Let us assume the user variable OFFICE was created, and the employees of location A have set it to "A", the employees of location B to "B". Now, you can create a parameter of type User variable for the report and select the variable OFFICE that you have defined before. (In the following example we assume to proceed on the basis of a dynamic list and a relational database.) Now, the query for the report can be designed as follows:

SELECT * FROM SALES WHERE SALES_OFFICE = ${OFFICE}
8.1. Defining User Variables

Before you can apply user variables, you have to create them.To do this, go to User management and select the root node (User root). Use the tab User variable management to add new user variables. You can choose from the following types:

Text variable Allows to set plain text
List Allows to set multiple values

When defining user variables you have to assign a name, and you can add a description at your discretion. To do this, click on the respective cell. You can define further properties for the variable by activating it and clicking on Edit in the tool bar.

8.2. Allocating User Variables

User variables are allocated to users directly from the User management. However, you can also assign user variables to organisational units. Here the user variable will be passed on to all users within the organisational unit. So it is possible to specify at the top organisational unit (User root) default values for variables which will overwrite the lower levels.

To specify user variables, select a user or an organisational unit and switch to the User variables tab. In the bottom table you see user variables which apply with this user/organisational unit by inheritance, and in the upper table you see the user variables specified here. To set a variable, click on Add and then select the desired variable. To specify the value of the variable, double click in the respective line of the table.

For text variables, enter the value in the entry field. For list parameters, you can enter the single values by separating them with | (pipe symbol).

8.3. Using User Variables in Reports

To use user variables in reports, create a parameter of type user variable and allocate the respective user variable to it. Now you can work with the parameter in the usual way. The replacement either hides an object of Type String (for a text user variable) or an object of Type Set <string> (for a list variable).