Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
james_lim
Advisor
Advisor
I made a simple prototype because a customer wants this feature.

Basically, Users don't want to see all menus (or links) because they never uses or not allowed to use those menu items so if we can hide/show menus based on user id, that will make simple UI/UX for end users.

 

Here is a screenshot of my prototype.

As you can see, there are four menus(Text widget) and one dropdown box.

When user is selected in the dropdown, then menu will be shown/hidden based on what he is allowed.

Those information is saved in a separate model and it should have user name from Empolyee dimension and menu dimension as in the table.


 

When user is selected,  Menu will be shown based on the definition in the model.

Menu1, Menu 3 and Menu 4 has value 1 so it is shown.


 

 

Here is the code of dropdown onclick event.

 

var strid = Dropdown_1.getSelectedKey();

if (strid === "0") {
Table_1.getDataSource().removeDimensionFilter("EMPLOYEE");
}

else {
       // Table Filter setting.

       //Note: if the dimension has hierarchy, you should specify the hierarchy name with       

        member id for filtering.

strid = "[EMPLOYEE].[HIERARCHY1].&[" + strid + "]";
Table_1.getDataSource().setDimensionFilter("EMPLOYEE",strid);
}

// get the table value and number of column for counting the number of menu
var col_count = Table_1.getColumnCount();
var data_set = Table_1.getDataSource().getResultSet();
var menu_flag = "";

// call a function to show or hide the menu.
for (var i=0; i < col_count; i++){
menu_flag = data_set[i]["@MeasureDimension"].rawValue;
      ScriptObject_1.setmenu(i, menu_flag);
}

 

Here is the code of setmenu in the ScriptObject_1. it just get the text Widget from the arr_text array.

function setmenu(arg1: integer, arg2: string) : void

if (arg2 === "1") {
arr_text[arg1].setVisible(true);
}
else{
arr_text[arg1].setVisible(false);
}

 

Then we need to put Text Widgets into the arr_text array.

it should be done in the canvas onInitialization() event.

 

arr_text.push(Text_1);
arr_text.push(Text_2);
arr_text.push(Text_3);
arr_text.push(Text_4);

 

The arr_text should be defined as Scripting variable.

 


Instead of using dropdown box, we can get the current user id in Analytics Designer app so we can  use it when the application is initializing.

It could be tricky to maintain users and menus but it will be one time maintenance task and can be done by functional team instead of technical team. Therefore, I believe it can be a good option to do.

It is a prototype so if anyone has better idea, please leave a comment 🙂

Thanks!

 

 

 

 
3 Comments