PAR Dashboard in UI Builder page - globalFilters seem to be ignored when exporting/printing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Hi
I have managed to embed a PAR Dashboard component in a Viewport using UI Builder - with this I can inject filters into the dashboard (see pic below) - and when run within application workspace I can see the dashboard is filtered.
Two questions:
1) when actions are used from the shown dashboard - "Export" (to PDF or Powerpoint) or "Printer Friendly" - both of these ignore the filters - e.g. counts are across all records, rather than filtered.
2) is there a way to force a refresh from the app? I don't see an option on the config (below) - but am considering added (say) a timestamp into the filters - which I could update to (possibly) force a refresh - but seems a bit of a sledgehammer.
UI Builder Dashboard Component Config
Once I load data I use a client script to inject the `globalFilters` link this.
function handler({api, event, helpers, imports}) {
try {
const { sysId } = api.context.props;
const detail = event.payload.data.output.data;
const ids = detail.items.map((r) => { return r.sys_id; });
const globalFilters = {
encodedQueries: {
x_myscope_app_table1: `sys_id=${sysId}`,
x_myscope_app_table2: `sys_idIN${ids.join()}`,
x_myscope_app_table3: `table1_ref=${sysId}`,
x_myscope_app_table4: `table1IN${ids.join()}`,
}
};
api.setState('globalFilters', JSON.stringify(globalFilters));
api.setState('dashboardId', 'b9c101f91b271a10357dc883604bcbfb');
api.setState('loading', false);
}
catch (e) {
console.error(`Error [ui-details]`, e, e.stack);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Friday
1) Exports/Print ignore injected filters
What’s happening (by design): the UI Builder “globalFilters”/context you inject at runtime aren’t part of the dashboard’s saved view. The built-in Export / Printer-friendly actions execute server-side using the dashboard’s saved state (or named view). Result: your runtime filters are not applied.
Practical ways to fix it
Best practice: create a Named View (dashboard view) that contains the filter preset you need, and set the UIB PAR component to load that view. Exports/print will honor it.
Dynamic exports (workaround):
On user action, persist the current injected filters into a temporary personal view (server script/subflow).
Call the export using that view id.
(Optionally) delete/expire the temp view.
Alternate UX: instead of using the component’s default Export/Print menu, add your own “Export” button in UIB that:
Ensures a matching named view exists (create/update if needed), then
Opens the export/print target with that viewId.
If you must pass filters via URL: use the dashboard runtime URL with view/context parameters (only parameters supported by PAR runtime are honored; arbitrary UIB globalFilters are not).
TL;DR: Exports/print only respect dashboard-internal state (saved/named view or supported URL context), not the UIB component’s injected props.
2) Forcing a refresh from the app (without sledgehammer tricks)
There’s no explicit “refresh” input on the PAR component, but you can rebind or change identity of a bound prop to trigger a refresh:
Options that work well:
Change the globalFilters object identity. In UIB, don’t mutate the same object; replace it (e.g., add a benign nonce property). The component re-evaluates on reference change.
Example: keep a local state refreshNonce = Date.now(), and bind globalFilters = { ...filters, _nonce: refreshNonce }. Updating the nonce forces re-compute.
Toggle the viewId. If you use a named view, briefly set the component to a fallback view (or null) and then back to the desired viewId in the same action flow to remount.
Pub/Sub event (if available in your version): some PAR widgets listen for an internal refresh/reload event. In UIB, add an “Emit event” client action targeted at the dashboard component (if your component exposes an event target); otherwise use the identity-change trick above.
Refresh the data source feeding filters (if you bind via Data Resources) and then bump the globalFilters identity so the component picks up the new values.
Avoid: adding timestamp filters that alter metrics—use a nonce field that the dashboard ignores, just to change the prop identity.
Suggested implementation pattern
Named views for export
Build a Named View per export scenario (e.g., “Ops_Region_EU_Q4”).
Bind the component’s viewId to that view when the user chooses the scenario.
Hide the default Export/Print menu and offer a custom “Export” button that always exports that viewId (so the result matches what the user sees).
Programmatic refresh in UIB
Add a Client State Parameter refreshKey.
Bind PAR component’s globalFilters to a computed object that includes refreshKey.
When you need a refresh, set refreshKey = Date.now() (or increment). The component will refresh without changing business filters.
Quick checklist
Exports/print won’t apply ad-hoc injected filters → use Named View or pre-persist filters.
Do not rely on object mutation; change object identity to refresh.
Prefer a custom export action that pins a view, so exported counts match on-screen counts.
If you need frequent dynamic exports, create short-lived personal views programmatically and export against those.
