How can I tell if a particular report is being used on any dashboards or homepages?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2020 08:23 AM
We are trying to do some cleanup on reports that haven't been run in the last year. I'm trying to avoid accidentally deleting some reports that may be used elsewhere such as on a Dashboard or Homepage.
I know that when a dashboard or homepage is run, it updates the "last run" field on the report stats; however, there is a case where the dashboard might not have been looked at in the last year as well. I'd like to avoid deleting reports on these aged dashboards if at all possible.
- Labels:
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2020 09:19 AM
I quickly wrote this a while back. It may help with homepages, but not for dashboard (can't help you there, at the moment).
The script below can be used as a background or fix script (better for reusability). Grab an encoded query from the report_stats table, plug it in to the first variable, run the script. From there, it'll run through everything that matches your query (eg, not run in last 6 months), then check and see if the report exists on any homepage sections, and grab the related homepage. It could likely use some tweaking, but it gets the job done
var lastRunQuery = "sys_updated_on<=javascript:gs.beginningOfLast6Months()"; //plug in your encoded query from report_stats here
var generateReportList = new GlideRecord("report_stats");
generateReportList.addEncodedQuery(lastRunQuery);
generateReportList.query();
if (generateReportList.hasNext()) {
while (generateReportList.next()) {
var reportLocations = new GlideRecord("sys_portal_preferences");
reportLocations.addEncodedQuery("value=" + generateReportList.report_sys_id);
reportLocations.query();
if (reportLocations.hasNext()) {
while (reportLocations.next()) {
var sectionLists = new GlideRecord("sys_portal");
sectionLists.addEncodedQuery("sys_id=" + reportLocations.portal_section);
sectionLists.query();
while (sectionLists.next()) {
gs.print("'" + generateReportList.report_sys_id.getDisplayValue() + "' is on " + sectionLists.page.getDisplayValue());
}
}
} else {
gs.print("'" + generateReportList.report_sys_id.getDisplayValue() + "' is not on a home page");
}
}
}
else{
gs.print("No aged reports to remove");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2022 07:14 AM
I notice that this does not show reports that are on the ITIL Homepage when running it. why is that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2020 11:25 AM
Hi Danielle! I'm curious if you ever got what you needed from your original question? I'm needing to do something similar and don't want to reinvent the wheel to make it happen if someone else has already figured it out.
Thanks,
Brandon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2020 02:08 PM
Hello Danielle and Brandon,
I as well need something like this, but not scripted... I don't want to reinvent the wheel either 😉
I manage dashboard and report metrics using the free reporting tools in ServiceNow. We reuse many metric visuals on our dashboards and I want to ensure when I make changes or delete a report, other dashboards are not negatively impacted.
Currently I don't see a way to dot walk from reports to dashboards, so I can't query a list of dashboards that are using a single report. This is really missing in the platform. We will not be purchasing the PA package in the future, so I need to find a solution in the base OOB platform.
Thank you,
Wendy