Questions on Conditional Loading and Filtering in Platform Analytics Dashboard

Bhanu29
ServiceNow Employee

 

Hi Team,

 

I am currently using the Platform Analytics dashboard component in our Digital Product Release application. We have integrated the dashboard component using UI Builder, and I have a couple of questions regarding its behavior:

  1. Is it possible to load a specific dashboard conditionally based on certain logic? I understand that this can be achieved using the dashboardSysId property; however, this property is not exposed in the UI. Could you please advise on how we can leverage dashboardSysId to implement conditional dashboard loading?
  2. If we need to filter dashboard data based on a specific sys_id (for example, to display records related to a particular release), what would be the recommended approach to achieve this?

1 REPLY 1

Ankur Bawiskar
Tera Patron

@Bhanu29 

My responses inline

1) Is it possible to load a specific dashboard conditionally based on certain logic? I understand that this can be achieved using the dashboardSysId property; however, this property is not exposed in the UI. Could you please advise on how we can leverage dashboardSysId to implement conditional dashboard loading?

-> Create a Client State Parameter (e.g., selectedDashboardSysId) in UI Builder.

-> Use a Scripted Data Resource or event handler to set its value conditionally:

-> ensure your dashboard has this workspace added in "Dashboard Visibility" field

// Example script in Data Resource (Server Script)
(function() {
    var condition = /* your logic, e.g., based on gs.getUser().hasRole('admin') */ ;
    if (condition) {
        return 'sys_id_of_dashboard_1'; // Fetch from pa_dashboards table
    } else {
        return 'sys_id_of_dashboard_2';
    }
})();

-> In the component properties (JSON mode or via binding), set defaultDashboard to ${states.selectedDashboardSysId}

Dashboard component properties 

 

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader