Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Dashboard Interactive Filter

ChezAndrewI0898
Tera Contributor

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.

3 REPLIES 3

Its_Azar
Mega Sage

Hi there @ChezAndrewI0898 

 

you can pass the filter value to a widget using URL parameters or GlideRecord queries in the widget's server script.

 

  1. 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. 

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,
Azar
Serivenow Rising Star
Developer @ KPMG.

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.

ChezAndrewI0898
Tera Contributor

Also, I can't seem to get the URL parameter from dashboard widget.