Interactive Filter setup to show specific choices for task type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2017 10:52 AM
Is there a way to setup interactive filters to only show specific task types? I only need to show a list of about 5 different task types. I have set up the interactive filter as a choice list, but I shows all task types in the drop down. I see there is an exclusions list, but that is adding a lot of exclusions to narrow down the scope to 5 types.
Thanks!
Alex
- Labels:
-
Analytics and Reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2023 05:54 AM
You need to update this and implement the method
SNC.canvas.interactiveFilters.setDefaultValue
I have updated the code for a diffrent interactive filter here, hope that gets you on track!
Codeexample:
this https://github.com/arnoudkooi/snippets/blob/master/OR%20Interactive%20Filter%20Updated.xml
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2023 06:05 AM
Hi @Arnoud Kooi many thanks for coming back to us - so very much appreciated.
Here below is the code (of yours) that I am trying to use.
How would this look if fully updated as you you suggest so that this code fully works?
Many thanks.
<?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_tasktypes" object="true" jelly="true">
var tables = 'incident,problem,change_request,task';
var obj=[];
var gr= new GlideRecord('sys_db_object');
gr.addEncodedQuery('super_classISNOTEMPTY^ORname=task^nameIN' + tables);
gr.addOrderBy('name');
gr.query();
while(gr.next()){
obj.push([gr.getValue('name'),gr.getValue('label')]);
}
obj;
</g:evaluate>
<select id='filter_task_type' class='select2-search' onchange='filterTaskType()'>
<option value="">All</option>
<j:forEach var="jvar_tasktype" items="${jvar_tasktypes}">
<option value="${jvar_tasktype[0]}">${jvar_tasktype[1]}</option>
</j:forEach>
</select>
<script>
var dbh = new DashboardMessageHandler("filter_tasktype");
function filterTaskType(){
var taskType = $j('#filter_task_type').val();
if (taskType)
dbh.publishFilter('task','sys_class_name=' + taskType);
else
dbh.removeFilter();
}
filterTaskType();
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2023 06:08 AM
Analyze how that other Interactive Filter Implements the SNC.canvas.interactiveFilters.setDefaultValue and mimic that in this usecase.
I don't have the bandwidth now to dive into this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2023 07:02 AM
@Arnoud Kooi I unfortunately cannot get that script code working in Tokyo (the one above which filters Dashboard Widgets for 'Task Type', using the above script you shared about 5 years ago), even after trying to incorporate the above (SNC.canvas.interactiveFilters.setDefaultValue).
If you ever get a chance to look again and revisit the script so that it works, please do kindly share with me down the line.
I understand you may be busy and not have the bandwidth so I completely understand, but if you ever get a chance oneday, I would be greatly appreciative of your help Arnoud, kind sir.
Kindest Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2023 07:35 AM
Please change the line
var dbh = new DashboardMessageHandler("filter_tasktype");
To
var dbh = new DashboardMessageHandler("filter_tasktype", function () {
SNC.canvas.interactiveFilters.setDefaultValue({
id: "filter_tasktype",
filters: [{ table: "task", filter: "" }]
}, false);
});
You can adjust the default filter to your needs, I now left it empty but you could make it like:
"task_typeIN" + tables
