Restricting a tab in an SAP Lumira Designer dashboard for a specific set of users, so not every user can view all the data that is provided in the dashboard. Here, we are going to explore the below actions-
- Implementing user-based security on a dashboard using BEx queries
- Hiding UI elements based on the BW user
Wondering if it’s possible? Yes, it is!!!
What we’re looking at achieving
Consider a dashboard where the Retail Sales Details are presented. It has two tabs, one is ‘Sales’ and the other is ‘Customer’. The UI elements such as the Customer tab inside this application needs to be hidden or displayed depending on the user accessing the application. In the example below, BW is used as the back-end source and TEXT components are used for building tabs, not tab-strips.
Achieving it with a BEx query
All that is needed is a Query which contains the User list and their access flag value. I’m using BW as my backend, so I’ve created a separate BEx Query that contains only User names and access values.
In HANA, the same functionality can be achieved by creating a table.
Note : The flag value can be defined as either a Key Figure or a Characteristic. We can handle it in SAP Lumira Designer using scripting. If it is a KF, declare it as 1 or 0 (Of course, 1 is for Users who have access and 0 for No Access)
Please refer the below image which represents the outline view of our application. Consume this query in SAP Lumira Designer as a Data Source. Here, it was named as DS_USERS. Make sure that Member for Filtering in the Edit Initial View of the Data Source is Only Values with Posted Data.
TEXT component is used for creating tab. Another TEXT needs to be inserted on the top of Customer tab TEXT Component.
It is named as TEXT_TAB_CUST_MOCK. Given Below is the BIAL script that must be executed when the application opens (it can be directly written in APPLICATION properties->onStartup() event).
1. Get the Username that is currently logged in and save it in a variable
2. Declare a Boolean variable that’s initial value is false. This can be used for flagging (mark an item’s property/value for attention).
3. If the Access Value is created as a Characteristic, then follow this step or go to step 4.
(1) Apply filter on DS_USERS with the “Y” value. “Y” is the value given for the users who can see the tab.
(2) Now get members of the dimension USER in an array variable. (We need only the filtered values, i.e, the list of users who can access the tab. It’s better if you can filter them in the BEx query itself. But in this case, that option can’t be availed).
The code is as follows
(3) Check whether the logged in User name is in the filtered list or not. If it is there, set the flag value as true, else the flag value will remain as false.
Now you can directly go to Step 5
4. If the Access value is defined as Key Figure, then get the data for the particular user who is logged in currently. If the data value is 1, then set the flag value as true else the flag value will remain as false.
5. Set visibility to TEXT_TAB_CUST_MOCK based on the flag value.
- If flag is true, then the user should access the customer tab, so this mock screen needs to be hidden. That is, set visibility – false.
- If the flag value is false then the user should not access the tab, the mock screen need to be shown. That is set visibility – true.
So I’m writing the code as below,
6. If the tab is not going to be shown, the user need not know that such a tab exists. For UI / aesthetics, the first-tab’s layout properties are changed; so it fits the entire page width. The same CSS class that is applied on the selected tab (Sales Tab) needs to be applied on TEXT_TAB_CUST_MOCK and its text-align should be left.
Consolidated scripts are given below –
(i) If Access Value was defined as a characteristic please use below code.
(ii) If Access Value was defined as a Key Figure please use this code.
What the implemented solution looks like
Result of the application looks like below for the user who has access to the Customer Tab.
Result of the user who doesn’t have access to the customer tab looks like below,
Both outputs are from the same Dashboard!!!
Got questions? Click here to get in touch.