Provides methods to define custom filtering logic for interactive filters.

For more information about interactive filters, see reporting and interactive filters.

DashboardMessageHandler - DashboardMessageHandler(String id)

Instantiate a DashboardMessageHandler object with a given unique ID.

Table 1. Parameters
Name Type Description
Id String A unique ID for the filter. This ID allows report widgets to track which filter applied each filter. The ID does not need to be unique across all dashboards, but each dashboard cannot have multiple filters with the same ID.

Example

var my_dashboardMessageHandler = new DashboardMessageHandler("my_unique_id");

DashboardMessageHandler - publishFilter(String table, String encodedQuery)

Each DashboardMessageHandler object can publish a single filter.

Publishing a new filter from the same object overwrites the original filter. Use multiple DashboardMessageHandler objects to publish multiple filters.

Table 2. Parameters
Name Type Description
table String The table to filter, such as task.
encodedQuery String An encoded query that specifies the filter to publish.
Table 3. Returns
Type Description
void

Example

var my_dashboardMessageHandler = new DashboardMessageHandler("my_unique_id");
<input id="onlyMine" type="button" value="Only mine" 
  onclick="my_dashboardMessageHandler.publishFilter('task','caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe');"/>

DashboardMessageHandler - publishMessage(Array filters)

Apply a custom interactive filter to multiple tables.

Table 4. Parameters
Name Type Description
filters Array Array of filter objects that define the tables to filter and the filter criteria.
[
  {
    "table": String,
    "filter": String 
  }
]
filters.table String Name of the table to filter.
filters.filter String Encoded query containing the filter criteria to apply to the table.
Table 5. Returns
Type Description
None

Example

This jelly script filters the Incident and Problem tables to return records where the assignment group is Problem solving.

<?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 dmh = new DashboardMessageHandler("aha_dmh");
 var filter = "cmdb_ci.sys_idINcdafbfc9db8f570466e0a345ca96198a"; 
 //this is the encoded query string
 var fullFilter = dmh.getFilterMessage('change_request',filter); 
 //creates a JSON object

 SNC.canvas.interactiveFilters.setDefaultValue({id: dmh.aha_dmh, filters:[fullFilter],}, false);
 var published = dmh.publishMessage([fullFilter]);
</script>

</j:jelly>

DashboardMessageHandler - removeFilter()

Removes the current filter published by this DashboardMessageHandler object from all reports on the dashboard.

Table 6. Parameters
Name Type Description
None
Table 7. Returns
Type Description
void

Example

var my_dashboardMessageHandler = new DashboardMessageHandler("my_unique_id");
<input id="removeFilter" type="button" value="Remove filter" 
  onclick="my_dashboardMessageHandler.removeFilter();"/>