Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Interactive Filters not working on variable values.

Prithvi Ramesh1
Mega Sage

Content Block code - 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide">

  <!-- Evaluate and fetch choices for the variable -->
  <g:evaluate var="jvar_status" object="true" jelly="true">
    var statusArray = [];

    // Replace with your variable's sys_id
    var gr = new GlideRecord('question_choice');
    gr.addEncodedQuery('question=e1135065b9766610c629de285ff18192');
    gr.addOrderBy('name');
    gr.query();

    while (gr.next()) {
      statusArray.push([gr.getValue('value'), gr.getValue('text')]);
    }

    statusArray;
  </g:evaluate>

  <!-- Dropdown for filtering statuses -->
  <select id="filter_statuses" class="select2-search" onchange="filterStatus()">
    <option value="">All</option>
    <j:forEach var="jvar_state" items="${jvar_status}">
      <option value="${jvar_state[0]}">${jvar_state[1]}</option>
    </j:forEach>
  </select>

  <!-- Script to handle filtering -->
  <script>
    var dbh = new DashboardMessageHandler("filter_status");

    function filterStatus() {
      var status = $j('#filter_statuses').val();

      if (status) {
        // Replace with actual sys_ids for catalog item and variable
        dbh.publishFilter(
          'sc_req_item',
          'cat_item=3ee0d861b9366610c629de285ff1812d^variables.e1135065b9766610c629de285ff18192=' + status
        );
      } else {
        dbh.removeFilter();
      }
    }

    // Apply filter on load
    filterStatus();
  </script>

</j:jelly>

 

PrithviRamesh1_0-1754052461235.png

 

The above screenshot shows that the dropdown values are coming as expected, but it is not reflecting in the dashboard.

1 REPLY 1

Bhavya11
Kilo Patron
Kilo Patron

Hi @Prithvi Ramesh1 ,

 

can you please check below widget  configuration over the report widget title bar and select the settings cog to open the widget configuration. Select checkbox "Follow interactive filters" & "Show when following interactive filters".

 

Bhavya11_0-1754287384518.png

 

 

for reference : Custom Interactive filter based on Catalog item variables

 

Thanks,

BK