Custom interactive filter for text search not working

gjz
Mega Sage

I need to be able to create a custom filter for a dashboard that allows a user to search on the short description instead of the number for a reference filter.  In this case, the need to be able to search for a Demand's short description (name) instead of the number - which is what is available if I create a reference interactive filter.

 

I've searched the community and have found lots of posts, including the one with a link to K19's creator con, and I've copied them exactly but my code doesn't do anything.  I've also checked the examples in the documentation, still doesn't work.  I've noticed all of these posts are pre-San Diego and Polaris, I'm wondering if they are no longer valid and I need to be doing something else?

 

Here's what I've done:

1. Created a test dashboard and added a test report based on the Demand table (dmn_demand).  It's just a simple list report, nothing special.

2. In the dashboard, selected the Widget category of Content Blocks -> *New Dynamic Content and added it to the dashboard.

3. Once I click on the  Create a content block link, I filled out the form and added my code.

4. Back on the dashboard, I entered a search term that I know exists because I can see it in the demand list - but it doesn't do anything.  I have verified the report is following the interactive filter.

 

Does anyone know what I'm missing?

 

My Dynamic Content block is called Demand Short Description and here is the code:

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
    <script>
    var my_dashboardMessageHandler = new DashBoardMessageHandler("FilterShortDescription");
 
    function publishFilter (searchTerm) {
        var filter_message = {};
        filter_message.id = "FilterShortDescription";
        filter_message.table = "task";

        if (searchTerm == "") {
            clearFilter();
        } else {
            filter_message.filter = "sys_class_name=dmn_demand^short_descriptionLIKE" + searchTerm;
        }
        SNC.canvas.interactiveFilters.setDefaultValue({
            id: filter_message.id,
            filters: [filter_message]
        }, false);
        my_dashboardMessageHandler.publishFilter(filter_message.table, filter_message.filter);
    }

    function clearFilter() {
        var filter_message = {};
        filter_message.id = "FilterShortDescription";
        filter_message.table = "task";
        filter_message.filter = "";
        SNC.canvas.interactiveFilters.setDefaultValue({
            id: filter_message.id,
            filters: [filter_message]
        }, false);
        my_dashboardMessageHandler.removeFilter();
    }
    </script>

    <input id="searchTerm" type="text" class="form-control" value="" onChange="publishFilter(this.value);"></input>

</j:jelly>
 
Does anyone know what is missing?
 

 

 

1 REPLY 1

Jmelendez
Tera Contributor

Simply add a Space after LIKE for the filter message. 

filter_message.filter = "sys_class_name=dmn_demand^short_descriptionLIKE " + searchTerm;