
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 11:04 AM
I would like to add an Interactive Filter to a Dashboard that allows the user to filter the reports based on if the record's Company field is CompanyA, or, not CompanyA.
If 'Is CompanyA' is selected, it should filter the reports to only show records for CompanyA.
If 'Is Not CompanyA' is selected, it should filter the reports to show records from all companies, except CompanyA.
If neither is selected (filter is not used), the reports show records for all companies, including CompanyA.
CompanyA is my company. All the other companies are customers. This filter would allow me to use the same reports for reporting on all tickets, internal tickets, and/or customer tickets.
If I could figure this out it would be a huge help and reduce the number of dashboard tabs and reports I'll need to create.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 01:33 PM
I created this, which works per your requirements
Put this code in a dynamic content block (instructions are in the article that I sent before). This is a good starting point. just replace the sys_id with your company sys_id. You can also add some css styles/formatting to the buttons if necessary.
<?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 my_dashboardMessageHandler = new DashboardMessageHandler("my_unique_id");
function compA() {
var filter_message = {};
filter_message.id = "my_unique_id";
filter_message.table = "task";
<!-- Add your own filter query logic here -->
filter_message.filter = "company=31bea3d53790200044e0bfc8bcbe5dec"; //SysID of company to show
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
my_dashboardMessageHandler.publishFilter(filter_message.table, filter_message.filter);
}
function notComA() {
var filter_message = {};
filter_message.id = "my_unique_id";
filter_message.table = "task";
<!-- Add your own filter query logic here -->
filter_message.filter = "company!=31bea3d53790200044e0bfc8bcbe5dec^ORcompany=NULL"; //SysID of company to exclude
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
my_dashboardMessageHandler.publishFilter(filter_message.table, filter_message.filter);
}
function clearFilter() {
var filter_message = {};
filter_message.id = "my_unique_id";
filter_message.table = "task";
filter_message.filter = "";
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
my_dashboardMessageHandler.removeFilter();
}
</script>
<input id="allTasks" type="button" value="All tasks" onclick="clearFilter();" />
<input id="CompA" type="button" value="Company A" onclick="compA();" />
<input id="notCompA" type="button" value="Not Company A" onclick="notComA();" />
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 11:23 AM
You'll need to create a custom interactive filter for this
this is a similar example taken from the link above
Define filtering logic - example
After you create the interactive filter, add the filtering logic.
Before you begin
Role required: admin
Procedure
- In the dynamic content record, add the filtering logic to the Dynamic content XML block.
- The Only mine button publishes a filter on Task table reports using the encoded query caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe. The All tasks button removes the filter.
- You can then add buttons or other interface elements to the dynamic content. In this example, the code for the clearFilter() function and the buttons in the filter are added below the publishFilter() function.
<?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 my_dashboardMessageHandler = new DashboardMessageHandler("my_unique_id"); function publishFilter () { var filter_message = {}; filter_message.id = "my_unique_id"; filter_message.table = "task"; <!-- Add your own filter query logic here --> filter_message.filter = "assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe"; SNC.canvas.interactiveFilters.setDefaultValue({ id: filter_message.id, filters: [filter_message] }, false); my_dashboardMessageHandler.publishFilter(filter_message.table, filter_message.filter); } function clearFilter() { var filter_message = {}; filter_message.id = "my_unique_id"; filter_message.table = "task"; filter_message.filter = ""; SNC.canvas.interactiveFilters.setDefaultValue({ id: filter_message.id, filters: [filter_message] }, false); my_dashboardMessageHandler.removeFilter(); } </script> Example of a filter that generates a static filter on 'task' table reports, or removes it <br/> <input id="allTasks" type="button" value="All tasks" onclick="clearFilter();" /> <input id="onlyMine" type="button" value="Only mine" onclick="publishFilter();" /> </j:jelly>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 12:34 PM
Can anyone help me with the scripting? I am very new to JavaScript.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 12:41 PM
Which reports/table are you trying to filter based on company. Incident table?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 01:03 PM
Hi Mike, there is a mixture of reports on the Dashboard, using the Incident and Task [task] tables.
I also realized that instead of directly using the Company name, I need to use 'contains' logic. There are a number of companies that contain 'CompanyA'.
With that in mind, my requirements would look more like:
- If 'Is CompanyA' is selected, it should filter the reports to only show records for companies that contain 'CompanyA' in the name.
- If 'Is Not CompanyA' is selected, it should filter the reports to show records from all companies that do not contain 'CompanyA' in the name.
- Then based on the example, I would need a third button that would filter the reports to show records for all companies.
Thanks for you help!