cancel
Showing results for 
Search instead for 
Did you mean: 

Filter by loginID

Rkile
8 - Cloud Apps
8 - Cloud Apps

I am curious about the options in locking a filter by a userID login?  If a user logs in, is there a way to limit a dashboard to only showing metrics pertaining to that user via the filters without the user being able to update these filters? 

2 ACCEPTED SOLUTIONS

harikm007
13 - Data Warehouse
13 - Data Warehouse

Hi @Rkile ,

Below dashboard script will set email ID of logged-in user as a filter and lock the filter:

dashboard.on('initialized', function (se, ev) {

	filter = se.filters.$$items.find(el=>el.jaql.title == 'User Email')//Update the name of filter
	
	defaultValue = prism.user.email

	filter.jaql.filter = {
   	 	"explicit": true,
    	"multiSelection": false,
    	"members": [
        defaultValue
    	]
	}
	
	filter.locked = true
	
	var filterOptions = {
							save: true,
							refresh: true,
						}
	
	se.filters.update(filter, filterOptions)
});

-Hari

 

View solution in original post

harikm007
13 - Data Warehouse
13 - Data Warehouse

Here is the updated script. Add emails of admin users to excludeList array.

dashboard.on('initialized', function (se, ev) {

	filter = se.filters.$$items.find(el=>el.jaql.title == 'User Email')//Filter Name
	
	excludeList = ['email1', 'email2']
	
	if(excludeList.includes(prism.user.email))
	{
		filter.jaql.filter = {
			"explicit": true,
			"multiSelection": false,
			"all":true
		}
		filter.locked = false
	}
		
	else
	{
		filter.jaql.filter = {
			"explicit": true,
			"multiSelection": false,
			"members": [
			prism.user.email
			]
		}

		filter.locked = true	
	}
	
	var filterOptions = {
							save: true,
							refresh: true,
						}
	
	se.filters.update(filter, filterOptions)
});

-Hari

View solution in original post

7 REPLIES 7

harikm007
13 - Data Warehouse
13 - Data Warehouse

Hi @Rkile ,

Below dashboard script will set email ID of logged-in user as a filter and lock the filter:

dashboard.on('initialized', function (se, ev) {

	filter = se.filters.$$items.find(el=>el.jaql.title == 'User Email')//Update the name of filter
	
	defaultValue = prism.user.email

	filter.jaql.filter = {
   	 	"explicit": true,
    	"multiSelection": false,
    	"members": [
        defaultValue
    	]
	}
	
	filter.locked = true
	
	var filterOptions = {
							save: true,
							refresh: true,
						}
	
	se.filters.update(filter, filterOptions)
});

-Hari

 

Works perfectly, thank you!

Rkile
8 - Cloud Apps
8 - Cloud Apps

@harikm007 - I have a follow up to this.  It is possible to create a list of emails that this rule doesn't apply to? Say there are 3-4 users that can login and view the dash without any filtering taking place? (Like admins).  

harikm007
13 - Data Warehouse
13 - Data Warehouse

Here is the updated script. Add emails of admin users to excludeList array.

dashboard.on('initialized', function (se, ev) {

	filter = se.filters.$$items.find(el=>el.jaql.title == 'User Email')//Filter Name
	
	excludeList = ['email1', 'email2']
	
	if(excludeList.includes(prism.user.email))
	{
		filter.jaql.filter = {
			"explicit": true,
			"multiSelection": false,
			"all":true
		}
		filter.locked = false
	}
		
	else
	{
		filter.jaql.filter = {
			"explicit": true,
			"multiSelection": false,
			"members": [
			prism.user.email
			]
		}

		filter.locked = true	
	}
	
	var filterOptions = {
							save: true,
							refresh: true,
						}
	
	se.filters.update(filter, filterOptions)
});

-Hari

irismaessen
11 - Data Pipeline
11 - Data Pipeline

I'm sure that harik's script will work beatifully... but Sisense also has Data Security functionality that lets you limit on a row-level in the cube, what data any given user can or cannot see. Wouldn't that also do what you want?

Iris

Iris,

 

Do you have a link to more information on this?  Harik's script does work perfectly but I am open to seeing additional options.

Thanks,

Ryan

irismaessen
11 - Data Pipeline
11 - Data Pipeline

Sisense has documentation about Data Access Security. If you are already using the user login as a filter, you have this data in a table in your elasticube and you should be able to use it as the defining column for row-level data security.

Data Security can be set via the UI as Admin, or via API. There's even options for managers of teams to only see their own team's data. 

If you have a slightly more complex model, it can have implications for your data modelling, though.

Good luck!

 

Iris