Notifications

334 views

Description

Custom Interactive filters are scripted widgets (System UI > Widgets) that use the DashboardMessageHandler JavaScript class to define and publish report filters.

Administrators may create custom interactive filter widgets to provide advanced filtering options on dashboards.

https://docs.servicenow.com/bundle/newyork-performance-analytics-and-reporting/page/use/dashboards/concept/c_CustomPublishers.html

Having multiple calls to publishFilter() does not work and when the filter is changed, the condition that was last applied (which is saved in the user preferences) becomes applicable instead of the current filter.

Cause

It is expected of multiple calls to DashboardMessageHandler.publishFilter() to not work as the second call would clear off the filter applied in the first call.

Resolution

Use only one message handler and pass the filter messages in an array.

Instead of having code like this:
var dashboardMessageHandler1 = new DashboardMessageHandler();
var dashboardMessageHandler2 = new DashboardMessageHandler();
dashboardMessageHandler1.publishFilter("TABLE1", "CONDITIONS1");
dashboardMessageHandler2.publishFilter("TABLE2", "CONDITIONS2");

The above code should be converted to use publishMessage() function instead of publishFilter():

==============
var handler = new DashboardMessageHandler("HANDLER_NAME");
var filter1 = handler.getFilterMessage("TABLE1", "CONDITIONS1");
var filter2 = handler.getFilterMessage("TABLE2", "CONDITIONS2");

// Use this To Publish Filter
handler.publishMessage([filter1,filter2]);

// Use this To Remove Filter
handler.removeFilter();
==============

Article Information

Last Updated:2020-02-17 19:26:38
Published:2020-02-18