Challenge

 
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.
 
SAP Design Studio - Restricting Tab to Specific Users - 1
 

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.
 

SAP Design Studio - Restricting Tab to Specific Users - 2

Query Output


 
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.
 

Restricting Tab to specific users - 2.1 - SAP Lumira Designer

Edit Initial View


 
TEXT component is used for creating tab. Another TEXT needs to be inserted on the top of Customer tab TEXT Component.
 
SAP Design Studio - Restricting Tab to Specific Users - 3

Outline View of the Application


 
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
 
Restricting Tab to specific users - 6.1 - SAP Lumira Designer
 
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).
 
SAP Design Studio - Restricting Tab to Specific Users - 5
 
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.
 
SAP Design Studio - Restricting Tab to Specific Users - 6
 
(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
 
SAP Design Studio - Restricting Tab to Specific Users - 8
 
(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.
 
SAP Design Studio - Restricting Tab to Specific Users - 9
 
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.
 
SAP Design Studio - Restricting Tab to Specific Users - 10
 
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,
 
SAP Design Studio - Restricting Tab to Specific Users - 11
 
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.
 
Restricting Tab to specific users - 12.1 - SAP Lumira Designer
 
Consolidated scripts are given below –

(i) If Access Value was defined as a characteristic please use below code.
 
Restricting Tab to specific users - 12.2 - SAP Lumira Designer
 
(ii) If Access Value was defined as a Key Figure please use this code.
 
Restricting Tab to specific users - 12.3 - SAP Lumira Designer
 

What the implemented solution looks like

Result of the application looks like below for the user who has access to the Customer Tab.
 
SAP Design Studio - Restricting Tab to Specific Users - 13
 
Result of the user who doesn’t have access to the customer tab looks like below,
 
SAP Design Studio - Restricting Tab to Specific Users - 14
 
Both outputs are from the same Dashboard!!!

Got questions? Click here to get in touch.

Subscribe to our Newsletter

5600 Tennyson Pkwy
Suite 120
Plano TX 75024.

+1 888-227-2794

+1 972-232-2233

+1 888-227-7192

solutions@visualbi.com

Join Chris as he explains the latest BI applications, technology, and process trends which will shape reporting and analytics in 2018

You have Successfully Subscribed!