Forum Discussion

andrew's avatar
andrew
Cloud Apps
02-10-2023
Solved

Auto Filter on current user

Hi all,

I found this plugin which looked like it would do what I wanted:

Auto Add Filter Based On User - Sisense Support Knowledge Base

However I don't seem to be able to get it to work with our version? Does anyone know if this code is still current and if there is another way to grab the current logged in users email and pass to the dashboard filters?

Thanks

Andy

 

  • Hi andrew ,

    Try this dashboard script. (here update the variable filterName with name of your dashboard filter)

    dashboard.on('initialized', function (se) {
    	let filterName = 'User Filter' //change this name with your dashboard filter name
    
    	selectedFilter = se.filters.$$items.find(el=>el.jaql.title == filterName)
    	
    	if(selectedFilter)
    	{
    		selectedFilter.jaql.filter = {
    									"explicit": true,
    									"multiSelection": true,
    									"members": [
    										prism.user.email
    									]
    								}
    	}
    
    })

    -Hari

     

  • andrew's avatar
    andrew
    02-10-2023

    Thanks Hari - worked like a Charm.

2 Replies

Replies have been turned off for this discussion
  • harikm007's avatar
    harikm007
    Data Warehouse

    Hi andrew ,

    Try this dashboard script. (here update the variable filterName with name of your dashboard filter)

    dashboard.on('initialized', function (se) {
    	let filterName = 'User Filter' //change this name with your dashboard filter name
    
    	selectedFilter = se.filters.$$items.find(el=>el.jaql.title == filterName)
    	
    	if(selectedFilter)
    	{
    		selectedFilter.jaql.filter = {
    									"explicit": true,
    									"multiSelection": true,
    									"members": [
    										prism.user.email
    									]
    								}
    	}
    
    })

    -Hari

     

    • andrew's avatar
      andrew
      Cloud Apps

      Thanks Hari - worked like a Charm.