Dynamic Content page not working with reports for interactive filter after refresh

Travis Michigan
Mega Sage

I created an interactive filter using the instructions here and at first it appears to be precisely what I was looking for.  However after further testing, every time anyone loads the dashboard they have to uncheck and recheck the interactivity options to get it to work again. 
Here is the code I am using:

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

<g:evaluate var="jvar_status" object="true" jelly="true">
	
var statusArray=[];
<!-- Get choices of select box [status] and pass it to the widget UI -->
var gr= new GlideRecord('question_choice');
  gr.addEncodedQuery('question=941b40b897bb0e14a21b34f3a253af42'); <!-- replace the sys_id with the sys_id of your variable. -->
  gr.addOrderBy('name');
  gr.query();

  while(gr.next()){
    statusArray.push([gr.getValue('value'),gr.getValue('text')]);
  }
	
 statusArray;
</g:evaluate>
 
    <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>
     var dbh = new DashboardMessageHandler("filter_status");
		
     function filterStatus(){
        var status = $j('#filter_statuses').val();
        if (status)
            dbh.publishFilter('sc_req_item', 'cat_item=9fdc232897b70e14a21b34f3a253afa1^variables.941b40b897bb0e14a21b34f3a253af42=' + status); <!-- change the cat_item sys_id and variable.sys_id with actual sys id of catalog item and target variable. -->
        else
            dbh.removeFilter();
     }
     filterStatus();
</script>

</j:jelly>

 Any suggestions or advise would be appreciated!

1 REPLY 1

Travis Michigan
Mega Sage

To reiterate the problem, when you first load the page the filter does nothing.  If you remove the check from and then replace the check to:

TravisMichigan_0-1726770185817.png

 

It will function until you load the dashboard again (or refresh).  Then you have to uncheck and recheck that box again for the filter to do anything.