Creating Dynamic Content Block for Interactive Filter on label name field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 04:02 AM - edited 04-01-2024 06:25 AM
Is it possible to create an interactive filter based on tags?
Ive been following an article from the forum that showed creating a dynamic content block, but it is not working (code below) . The outline was to create a dynamic content block for an interactive filter on the label table (name field) for the label name. Article link: https://www.servicenow.com/community/performance-analytics-forum/how-to-create-an-interactive-filter...
(The dashboard is pointing to the demand form, so Im trying to specifically search demand that have certain labels)
The filter doesnt seem to work and produces no results (Doesnt change the content in the existing dashboard). Is there something missing/incorrect?
Edit: What I'm noticing is that the labels are stored in the label table, but those records have a label_entry value that seems to link the demand. Not quite sure then what the content block should include to produce the results needed.
<?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("123");
function publishFilter () {
var filter_message = {};
filter_message.id = "123";
filter_message.table = "label";
var value = gel('cfname').value;
filter_message.filter = "nameLIKE" + value;
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 = "123";
filter_message.table = "label";
filter_message.filter = "";
gel('cfname').value = '';
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
my_dashboardMessageHandler.removeFilter();
}
</script>
Tag:
<input id="name" type="input" value="" /><br/>
<input id="removeCustomFilter" type="button" value="Clear" onclick="clearFilter();" />
<input id="addCustomFilter" type="button" value="Search" onclick="publishFilter();" />
</j:jelly>