How can I add a search box to a dashboard to filter the results?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 12:07 PM
I have a widget on a dashboard which shows a report of open requests. I would like to add a search box to filter the request list. I have tried adding a Content Block widget, but the list values are not filtering. When I enter a value into the content block search field, the screen flashes like it is filtering, but all of the same values are returned.
The table name is 'u_itam2'
The field name to filter by is 'u_product_name'
The code for the content block is:T
<?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 dbh = new DashboardMessageHandler("");
function doSearch(evt){
if (evt === true || evt.which == 13){
var searchValue = $j('#itamSearch').val();
if (searchValue.startsWith("*"))
dbh.publishFilter('u_itam2','u_product_nameLIKE' + searchValue.replace("*",""));
else
dbh.publishFilter('u_itam2', 'u_product_nameSTARTSWITH' + searchValue);
}
}
</script>
<div class="input-group">
<input id="itamSearch" class="form-control"
type="search"
onkeyup="doSearch(event)"
placeholder="ITAM Product Name contains" />
<span class="input-group-btn">
<button type="button" class="btn btn-primary" onclick="doSearch(true)">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</j:jelly>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 03:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2020 06:54 AM
Thank you sachin.namjoshi,
I've tried adding the example filter from the custom interactive filter link. I replaced "task" with my table's name. I have a dashboard with an "All requests" report which renders 122 records when the dashboard loads. I added the test filter and configured the report widget to "Follow interactive filter". When I click the "Only mine" button or the "All tasks" button, the same 122 records are displayed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2021 02:33 PM
I have a list of 1000 unique catalog items. How would I filter that without creating a filter of 1000 checkboxes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 03:44 AM - edited 07-03-2023 04:53 AM
I am not sure, if your issue is resolved. I see this post as still not resolved.
The problem is with 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 dbh = new DashboardMessageHandler("search_id");
function publishFilter() {
var filter_message = {};
filter_message.id = "search_id";
filter_message.table = "u_itam2";
var searchValue = $j('#itamSearch').val();
filter_message.filter = 'u_product_nameLIKE' + searchValue;
// filter_message.filter += '^OR#ANY OTHER FIELD NAME#LIKE' + searchValue;
// If you want to search any other field in the report, add the system name in the #ANY OTHER FIELD NAME# section
// In this code, for all cases the stytem is doing a contains search. You can change the logic, based on the filter query that you like.
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
dbh.publishFilter(filter_message.table,filter_message.filter);
}
</script>
<!-- **** HTML Search Code Starts here **** -->
<div class="input-group">
<input id="itamSearch" class="form-control"
type="search"
onkeyup="publishFilter()"
placeholder="ITAM Product Name" />
<span class="input-group-btn">
<button type="button" class="btn btn-primary" onclick="publishFilter()">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</j:jelly>
Please mark the post as resolved and my suggestion as helpful, if it work for you. All the best.