Search bar missing within report on dashboard

joshdev
Kilo Explorer

I am building a dashboard.   On one of the tabs I've inserted a report from the Report module (which simply displays a bunch of fields/data).   I want the user to be able to search on a specific field (Configuration Item).   The user wants to be able to search for a specific CI.

What Ive tried:

Interactive Filter (configuration item).   This nearly broke the dashboard.   There are a 500k-1million+ records for CI and I nearly had to delete the tab and start over.  

Click into any CI displayed, and then the search bar under 'Configuration item' appears.   But the user does not want to do this.   He wants to be able to search directly from the Dashboard canvas.

Any ideas?

7 REPLIES 7

vedang_vaidya
Kilo Expert

I used to have this but post the PARIS version it has stopped working.

I tried working together with the HI Portal to solve this, and was guided to use this:

https://hi.service-now.com/kb_view.do?sysparm_article=KB0827667

https://hi.service-now.com/kb_view.do?sysparm_article=KB0823096

https://docs.servicenow.com/bundle/orlando-performance-analytics-and-reporting/page/use/dashboards/reference/r_CustomPublisherExample.html

 

However, I was still unable to. They did mention to try using custome interactive filter instead, which I've tried and failed for my requirement.

If anyone can give some ideas on this, it would greatly help.

 

Thanks & Regards,

Vedang Vaidya

They changed something with publishing filters for the Orlando release. You now have to call the SNC.canvas.interactiveFilters.setDefaultValue() method when publishing a filter. See more info here.

 

Here is a working version:

 

<?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("incident_ci_name_like");
 function doSearch(evt){
       if (evt === true || evt.which == 13){
   var fltr = $j('#tbxCiSearch').val();
	var filter_message = {};
   if (fltr.startsWith("*")) {
         filter_message.id = "ciFilter"
         filter_message.table = "incident"
	     filter_message.filter = "cmdb_ciLIKE" + fltr.replace("*","");
	SNC.canvas.interactiveFilters.setDefaultValue({
                id: filter_message.id,
                filters: [filter_message]
            }, false);
   dbh.publishFilter(filter_message.table, filter_message.filter);
	}
   else {
         filter_message.id = "ciFilter"
         filter_message.table = "incident"
	     filter_message.filter = "cmdb_ciLIKE" + fltr.replace("*","");
	SNC.canvas.interactiveFilters.setDefaultValue({
                id: filter_message.id,
                filters: [filter_message]
            }, false);
   dbh.publishFilter(filter_message.table, filter_message.filter);
   }
	}
}
</script>
<div class="input-group">
   <input id="tbxCiSearch" class="form-control" 
       type="search" 
       onkeyup="doSearch(event)" 
       placeholder="CI 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>

 

Try this out, and if it works, please mark this as helpful!

Jayvik
Tera Contributor

What look the code look like if it was the sc_req_item table and to "keyword" search all fields on that table?