User Variables

User variables are a way of storing data against a particular user. A good example for how to use a User Variable would be when you have multiple branches, and you want data for a particular branch to load by default when a user logs in. Although the user would also be able to access data from other branches if they needed to, the data for the branch they work at would be loaded as soon as they log in.

This functionality can be utilised for:

  • Data connection details. Different users can connect to different databases without having to set up multiple Data Connections.

  • Swap tables viewed within a connection. Different users can view database level restricted tables or views.

  • Swap SELECT, WHERE or ORDER BY clauses.

  • Pass date time format masks.

  • Apply filters in charts.

  • Change chart titles.

Variables are incorporated into the “Users” interface. To create a new variable, select the user on the left-hand side of the screen and click the Variables link.

To create a new variable, click the ‘Add’ icon on the right-hand side of the screen.

The user variable is now specified by typing the name of the Variable into the first column and the Variable Value into the second column. 

Example

In the following screenshot, we’ve added a Variable that will default the view to the Gateshead branch when the selected user logs in.

For all other users, the default branch will be Liverpool, which has been specified in the Settings menu of the Dashboard Configuration screen.

To add more variables for a user, click the ‘Add’ icon again and repeat the steps listed above.

User variables work in conjunction with system variables. 

If you have a system variable ‘USER_NAME’ set to ‘FRED’ then:

  • If a user has a user variable ‘USER_NAME’ of ‘JOE’ then for that user if will return ‘JOE’.

  • If a different user doesn’t have a user variable, then it will use the system variable ‘FRED’ instead. 

On the other hand, if you don’t have a system variable for ‘USER_NAME’ set then:

  • If a user has a user variable ‘USER_NAME’ of ‘JOE’ then for that user if will return ‘JOE’.

  • If a different user doesn’t have a user variable then there will be no system variable to fall back on, which could well cause problems. 

If you created a variable to store data connection username prior to version 2020-11-26 and you then upgrade to version 2020-11-26 or beyond you will need to tick the ‘Keep Secure’ box next to it for the data connection to work.

If a variable is added to the ‘User Variable’ section that matches a System or Environment Variable a warning message like the one shown below will be displayed. In the following example, a System Variable already exists, which has been made secure, when the same variable is added to the User Variable screen it will be automatically set to the same security level as the System Variable and this cannot be modified.

In addition to this, if you add the same variable name twice the following message will be displayed.

When Variables have been specified for a user, a number indicating how many variables will be displayed next to the Variables menu at the top of the screen.

Deleting User Variables

To delete a User Variable, select the User on the left-hand side of the screen and then click the Variables link. 

Click the ‘Remove’ icon next to the Variable that you want to delete.