Notifications

48 views

Introduction


Sometimes it may be useful to find usages of a report on Homepages and PA Dashboards. For example, you may want to remove or redesign a report, but want to measure the impact. The script in this article will search for Homepages and PA Dashboards that have this report.

Usage


The function in the script takes one argument. This should be a string containing the sys ID of the report (sys_report record) you are looking for. This script should be run via the Scripts - Background module.

The Script


findReportReferences('c8b0bce8db25b3003869ff041d961975');
function findReportReferences(report) {
    var pp = new GlideRecord('sys_portal_preferences');
    pp.addQuery('value', report);
    pp.query();
    while (pp.next()) {
        var page = new GlideRecord('sys_portal_page');
        page.get(pp.portal_section.page);
        var tabs = new GlideRecord('pa_tabs');
        tabs.addQuery('page', page.sys_id);
        tabs.query();

        // No PA tabs, it's just a homepage
        if (tabs.getRowCount() < 1) {
            gs.info("Homepage: " + page.title);
            continue;
        }

        // PA tabs exist, it's on a dashboard
        while (tabs.next()) {
            var m2m = new GlideRecord('pa_m2m_dashboard_tabs');
            m2m.addQuery('tab', tabs.sys_id);
            m2m.query();
            while (m2m.next()) {
                gs.info("Dashboard: " + m2m.dashboard.name);
            }
        }
    }
}

Article Information

Last Updated:2019-05-21 11:58:53
Published:2019-05-17