Can't remove DashboardMessageHandler filters in DynamicContentBlock
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 01:38 AM
Hi,
I created a dynamic content block solution for applying a tag/label filter to reports on a dashboard, using DashboardMessageHandler.
It works as expected, however, when setting the filtering value to empty or triggering the "clearFilter" function via a button, removal of the filters doesn't work (nothing happens).
I have it set up almost exactly like in the docs "Define filtering logic - example", the only difference is that I'm applying multiple filters with publishMessage() instead of publishFilter(). (Docs for this)
I even tried adding removeFilter() right after publishMessage(), and even that failed to remove the filter.
P.S. I realize the button and the clearFilter function is not in my below code anymore, this is the cleaned version, since I couldn't get the filter removal to work. But I had it set up exactly as in the Docs, and it wasn't working. Any ideas?
<?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>
<!-- Create DashboardMessageHandler instance -->
var my_dashboardMessagehandler = new DashboardMessageHandler("Tag-filter-task");
function getRecords(tag) {
// If the field is emptied, avoid applying an "invalid tag" filter
if(tag == "") {
return;
}
// Setting the query for the tag
var filterQuery = "sys_tags." + tag + "=" + tag;
// Set filter_message properties
var filterMessage1 = my_dashboardMessagehandler.getFilterMessage("task", filterQuery);
var filterMessage2 = my_dashboardMessagehandler.getFilterMessage("rm_doc", filterQuery);
var finalFilter = [filterMessage1, filterMessage2];
SNC.canvas.interactiveFilters.setDefaultValue({
id: "Tag-filter-task", //my_dashboardMessagehandler._unique_id,
filters: finalFilter
}, false);
// Sending the query to the dashboard
my_dashboardMessagehandler.publishMessage(finalFilter);
}
</script>
<!-- Create a label and add an OOB UI Macro for the tag reference field -->
<label id="tag_label">Choose the tag you want to filter for</label>
<g:ui_reference aria-labelledby="tag_label" name="tag" id="tag" table="label" onChange="getRecords(this.value);" show_popup="true" show_lookup="true" order_by="name" query="active=true^viewable_by=everyone^ORownerDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORgroup_listDYNAMIC14c62ab1b313401013a082c136a8dc3b^ORuser_listDYNAMIC90d1921e5f510100a9ad2572f2b477fe^nameSTARTSWITHF&R" />
</j:jelly>