Filter a dashboard by selecting fields in a custom widget on the portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello everyone,
I'd like your help designing and configuring the following requirement:
We have a Platform Analytics dashboard based on a custom table, which users are redirected to from a custom widget in the portal. The goal is that, based on the field selections in the widget (which displays information from the custom table), the user is redirected to the dashboard, applying the parameters already selected in the widget.
I tried passing the selections as URL parameters, but it didn't work.
Has anyone encountered a similar situation or have any suggestions?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Why are they not just navigating to the dashboard and using the filters? What is the benefit of this portal page?
Anyways, platform analytics preferences are stored in the "com.snc.par.dashboards.ui.preferences" userpref as json. The format should be pretty easy to figure out, the first level of keys is the dashboard sysid, in the filters object the key is the tab sysid.
Get the preference -> modify it -> save it. In the portal you can utilise spUtil | ServiceNow Developers or use the server-side script of the widget or the graphql user preference api or whatever. Take note if you use async methods that the preference needs to be updated before the filter loads
var pref = JSON.parse(gs.getUser().getPreference("com.snc.par.dashboards.ui.preferences"))
pref["02f2b19d83a33210557ff0d6feaad358"].filters["86f2f19d83a33210557ff0d6feaad3f8"].parFilters[0].values = [gs.getUserID()]
gs.getUser().setPreference("com.snc.par.dashboards.ui.preferences", JSON.stringify(pref))
