I wanted to use Cognos public Dashboard API only, but could not figure out how to get Page Context Items.
Original Message:
Sent: Tue July 30, 2024 06:22 PM
From: Paul Mendelson
Subject: Error in making a custom widget for reset filter to be applied in the dashboard
Hey Andrei,
That is true. I looked over the other version of it - if you want to skip the filters you have to pass exactly the items you want to delete. I'm not able to share the exact code I'm using, but I can walk you through the logic.
Start by getting the objects
let items = this.pcs.getPageContext().getPageContextItems();
filter out the filters and any other types you want to skip
items = items.filter(item=>item.getOrigin()!='filter');
For each element left in the items array you'll need to make an object and then run deletePageContextItems
myObj = {
eventGroupId: item.getEventGroupId()
, eventSourceId: item.getEventSourceId()
, hierarchies: item.getPageContextSpec().hierarchies
, hierarchiesContain: item.getPageContextSpec().hierarchies.map(x=>x.hierarchyUniqueName)
, hierarchyUniqueNames: item.getPageContextSpec().hierarchies.map(x=>x.hierarchyUniqueName)
, origin: item.getOrigin()
, scope: item.getScope()
, sourceId: item.getSourceId()
}
Once you get it everything should be peachy.

The premium version has the toggle for filters and data players. Are there other options I should add to it?
------------------------------
Paul Mendelson Product Manager
Product Manager
PMsquare
Original Message:
Sent: Tue July 30, 2024 04:53 PM
From: Andrei Istomine
Subject: Error in making a custom widget for reset filter to be applied in the dashboard
@Paul Mendelson
deletePageContextItems() will literally remove all filters from the Dashboard.
------------------------------
Andrei Istomine
Open to work - anything Cognos
https://www.linkedin.com/in/andreii/
Original Message:
Sent: Mon July 29, 2024 02:18 AM
From: Paul Mendelson
Subject: Error in making a custom widget for reset filter to be applied in the dashboard
I've added a clear filters widget to CogBox. I'm certain that IBM is going to be adding their own version of this at some point (right, IBM?), so I don't mind posting the code here. I've also attached the spec.json filtered down to only the js file.
The active section, the hard part to figure out, is this:
clearFilters(){
this.dashboard = __getDashboardAPI();
this.pcs = this.dashboard.getFeature('PageContextService');
if(localStorage['cogboxVerboseMode']) console.log('Clearing all local filters: ' + this.pcs.getPageContext().getPageContextItems().map(x=>x.getItemId()+ ': ' + x.getValues().map(v=>v.d).join(', ')) .join(', '));
this.pcs.getPageContext().deletePageContextItems();
}
Basically this will get call the PageContextService in the current dashboard. There's a handy-dandy function to delete all the context items in one shot. The premium version of this (forgive the tiny ad here, a man's gotta eat) will let the dashboard author specify context items to skip. So you could clear everything except for the data player.
------------------------------
Paul Mendelson Product Manager
Product Manager
PMsquare
Original Message:
Sent: Mon July 15, 2024 11:14 AM
From: Priya Sengar
Subject: Error in making a custom widget for reset filter to be applied in the dashboard
Hello All, I am currently working on a requirement to make a reset filter button using custom widget to be applied on a dashboard in the Cognos Version 11.2.4 by packaging custom HTML/JavaScript file and spec.json in a zip file. However when I upload the zip file under Manage-> Customization->Extensions I receive the error as given in the screenshot .
Please find the code of the custom HTML/JavaScript file and spec.json file . Also find the screenshot of the information obtained on using browser developer tools (right-click on the filter and select "Inspect" or press F12) to examine the HTML structure and identify the classes or IDs used for the filter applied on the dashboard
------------------------------
Priya Sengar
------------------------------