Dashboard Interactive Filter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 06:39 AM - edited 07-10-2024 06:55 AM
Use Case:
I have a dashboard with an Interactive Filter, Reports and Content Block in one tab, the content block is not following the interactive filter.
Is there any way I can get the interactive filter value to a widget?
For reference the Interactive Filter is custom, using UI Macro:
Custom Interactive Filter
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 10:14 AM
Hi there @ican
you can pass the filter value to a widget using URL parameters or GlideRecord queries in the widget's server script.
- make sure that the interactive filter sets a URL parameter when a value is selected.
<!-- Example custom UI Macro -->
<g:macro>
<select id="interactive_filter" onchange="updateFilter(this.value)">
<!-- Options here -->
</select>
<script>
function updateFilter(value) {
var url = new URL(window.location);
url.searchParams.set('filter_value', value);
window.location = url;
}
</script>
</g:macro>
Now upadte widget to use filter val
(function() {
// Get the filter value from the URL parameters
var filterValue = gs.getSession().getRequestParameter('filter_value');
// Use the filter value in your GlideRecord query
var gr = new GlideRecord('your_table');
if (filterValue) {
gr.addQuery('your_filter_field', filterValue);
}
gr.query();
var result = [];
while (gr.next()) {
result.push(gr.getDisplayValue());
}
data.result = result;
})();
If this helps kindly accept the respone thanks much.
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
Microsoft MVP (AI Services), India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 01:22 AM
This is very helpful, but this will refresh the page upon selecting filter.
Is there a way wherein the page wont reload and just append parameter on URL?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 04:52 AM
Also, I can't seem to get the URL parameter from dashboard widget.