To export the list of Reports attached to the Dashboards

Malathi3
Tera Contributor

Hello Everyone,

 

We are planning to migrate Core UI Dashboard to Platform Analytics Dashboard. We are able to get the total count of Dashboards and Reports directly by accessing the table.

 

But to cross-check, we are looking for the list of Reports that are attached to the Dashboard.

 

Could you please help with the script to get the list of Report Name + the corresponding Dashboard Name?

14 REPLIES 14

Please ignore the migration.

 

Now I am just looking for a simple script which gives the Dashboard name (pa_dashboards) table and the associated report name (sys_report table) in it.

 

To get the list: Dashboard Name + Report Name

 

 

I think if you go to the Admin Console and select all dashboards you will be able to see all reports that are part of a dashboard, it will be the fastest. 

I have tried with the below script but the Reports attached to the Dashboard is not showing in the output.

 

Could anyone please help to fix the script.

 

// 1. Query PA Dashboards (pa_dashboards)
var dashboardGR = new GlideRecord('pa_dashboards');
// Optional: Filter by active dashboards
// dashboardGR.addQuery('active', true);
dashboardGR.query();
 
gs.info("Starting to pull PA Dashboards and Reports...");
 
while (dashboardGR.next()) {
    var dashboardName = dashboardGR.getValue('name');
    var dashboardSysId = dashboardGR.getValue('sys_id');
   
    gs.info("--------------------------------------------------");
    gs.info("Dashboard: " + dashboardName + " [SysID: " + dashboardSysId + "]");
 
    // 2. Query Dashboard Tabs (pa_m2m_dashboard_tabs)
    var tabM2M = new GlideRecord('pa_m2m_dashboard_tabs');
    tabM2M.addQuery('dashboard', dashboardSysId);
    tabM2M.query();
 
    while (tabM2M.next()) {
        var tabName = tabM2M.tab.getDisplayValue();
        var tabSysId = tabM2M.getValue('tab');
       
        gs.info("  >> Tab: " + tabName);
 
        // 3. Query Widgets on Tabs to find Reports (pa_tabs/sys_portal_page)
        // This is complex as reports are embedded in widgets
        var tabContent = new GlideRecord('pa_tabs');
        if (tabContent.get(tabSysId)) {
            // Get the widget/report information
            // This is a simplified lookup; complex dashboards might need deeper analysis
            var reportGR = new GlideRecord('sys_report');
            // This assumes reports are directly linked to widgets
            // In many cases, you need to query sys_portal_preferences to link widgets to reports
           
            // Example to find widgets on page
            var portalPage = new GlideRecord('sys_portal_page');
            if (portalPage.get(tabContent.page)) {
                 // In a full implementation, you would traverse the widget tables (sys_grid_canvas_pane)
                 // For now, listing tab/dashboard to identify structure
            }
        }
    }
}
gs.info("Finished.");
 
 

Malathi3_0-1769096005556.png

 

or take a look at this:

https://www.servicenow.com/community/performance-analytics-blog/view-reports-on-a-dashboard-and-dash...

There is a script from Arjun Thakur posted on 12-07-2023 11:51 AM as part of that article

Hi Tsura,

 

I configured the same way in my PDI but still the Report section is showing empty.

 

Malathi3_0-1769099369360.png