- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2019 12:42 AM
Hello Team,
I am trying to add a filter for a string type field on the dashboard report table. I went through other community posts related to the same but didn't get much help on the code.
Please provide any example script to create a filter on string field.
Thank you in advance.
-Prabhh
Solved! Go to Solution.
- Labels:
-
Performance Analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2021 06:50 AM
Hey everyone!
I had a really hard time finding any useful material on this topic as most of the links are dead.
The requirement I got from a user was that they should be able to filter their reports on their dashboards by the Short Description of the task.
I ended up creating a dynamic content block to act as an interactive filter. I hope somebody in the future finds this useful!
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<style>
</style>
<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 = "short_descriptionSTARTSWITH"+ 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>
My end result looked something like this:
Ps.: I removed some parts of the sample script compared to what you can see on the screenshot. The sample script will only work with STARTSWITH search - so it should only act as a base which you can build upon.
You can add a couple of if conditions to make it "smarter", you may add your own CSS and HTML to the content block to make it work better with your own requirement.
Have a nice day!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2023 12:21 PM
Okay, so this is working for the Task table, but what if I wanted to expand this to additional tables (such as Interaction)?
Will this be able to check multiple tables with the same content block? (e.g. if I wanted it to filter the Incident Table and Interaction table)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2023 12:04 AM
How can we make it dynamic to search for Number, user_name, with a drop-down to select?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2023 09:02 AM
Hi,
Could you please tell me how you launch your script ?
kr,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2024 09:38 AM
Hello @Gabor10 ,
I've generated a report for the "incident_metric" table, and we need to retrieve the previous assignment group data. However, we must construct a filter on it in order to filter the previous group's data, and the only method to do so is to create a filter on the value field. We tried your script, but it isn't working for me. Could you kindly look at it?
Script -
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<style>
</style>
<script>
var my_dashboardMessageHandler = new DashboardMessageHandler("FilterShortDescription");
function publishFilter (searchTerm) {
var filter_message = {};
filter_message.id = "FilterShortDescription";
filter_message.table = "metric_instance";
if (searchTerm == ""){
clearFilter();
}
else {
filter_message.filter = "valueSTARTSWITH"+ 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 = "metric_instance";
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>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2024 04:23 AM
Hi @Gabor10 ,
I have same kind of requirement on kb_knowledge table. I just copied the code and changed the table name filter is working perfect.
Thanks for the code.
