Hide or show row in table based on role

Hello,

image

We are using Helical insight 4.1 EE GA edition. We have a tabular report and have various kind of roles. We want to selectively hid or show rows of data in table based on the role name. To be more specific on this above report we want to show column based on designation, e.g territory manager will have less column and regional manager will have some more column, kindly provide example on how to achieve this requirement

Thanks,
Netta.

Hello Netta,

It is difficult to provide a solution to this, as we need to have two different queries for two different scenarios, which ideally means two different reports. The workaround can be applied at the report rendering level which will have its own limitations.

However, we still have managed to achieve something wherein, you can put the below code and certain roles will not be able to see the columns. Please note that this is removing the column only at the HTML level but in the export level still all the columns will appear. This is happening as the report is getting all the columns as per the SQL and exporting is done based on SQL response. Hence if you would like to use, you can go ahead and use the below proposed solution. However, we strongly recommend that two different reports should be built for this purpose.

Explaining the code: you can see there is an if condition, in that if condition we are checking what is the role name and if the role name is matching we are specifying the column which will not be visible using !=


hi_container.set("preFetch",function(c){

var formData = c.get("requestData");

if(DashboardGlobals.user.roles.includes('ROLE_ADMIN') === true){

formData.columns = formData.columns.filter((item)=>item.column!='HIUSER.travel_details.mode_of_payment')

formData.functions.groupBy = formData.functions.groupBy.filter((item)=>item.column!='mode_of_payment')

}

else {

formData.columns = formData.columns.filter((item)=>item.column!='HIUSER.travel_details.destination')

formData.functions.groupBy = formData.functions.groupBy.filter((item)=>item.column!='destination')


}
c.set("requestData",formData);

});

Thanks,
Helical Insight.