Dashboard - Passing Filter Values Using URL Parameters
A customer may want to pass a filter value using the URL (as a parameter). A common case could be when an external system launches a dashboard and wants it to default to a specific value.
The following script allows you to parse the parameters received in the URL and apply them to the dashboard filters.
Steps:
1. Apply the following script to your dashboard:
dashboard.on('initialized', function(widget) {
// Get Parameters
urlParameters = window.location.href.substring(window.location.href.indexOf('?')+1).split('&')
// Parse Parameters
parameters = new Map();
urlParameters.forEach(function(param) { parameters.set(param.split('=')[0],param.split('=')[1]) })
prism.activeDashboard.filters.$$items.forEach(function(fil) {
if (parameters.get(fil.jaql.title) !== undefined) {
fil.jaql.filter.explicit = true
fil.jaql.filter.userMultiSelect = true
fil.jaql.filter.members = [parameters.get(fil.jaql.title)]
}
})
})
2. Acquire the URL of your dashboard
(e.g. https://test.sisense.com/app/main#/dashboards/62a...ae1)
3. Add parameters (align with filter names):
https://test.sisense.com/app/main#/dashboards/62a...ae1?Region123=US&CountryName=Iowa
4. Refresh the dashboard and watch your filters pane:
Published 06-09-2022
Ophir_Buchman
Data Integration
Joined October 19, 2021