Report View ACL Analysis
We were recently notified by ServiceNow that a batch of report view ACLs would be activated in our production instance if we did not activate them ourselves (see KB0958442). They provided a great analysis tool in the ACL Assessment for Reports. When that analysis came back saying we have hundreds of reports to review, we wanted a faster way to generate the list of all the potentially affected users instead of going through each report individually. If you're looking for something similar, this code should do it for you.
var limit = 50;
var c = 0;
var gg = new GlideRecord('report_view_acl_assessment');
gg.query();
while (gg.next()) {
var uu = new GlideRecord('report_view_acl_assessment_users');
uu.addEncodedQuery('report_view_acl_assessment=' + gg.sys_id);
uu.query();
if (!uu.hasNext() && c < limit) {
c++;
gs.print('checking ' + gg.report.title + ' (' + gg.report.sys_id + ')');
var worker = new GlideScriptedHierarchicalWorker();
worker.setScriptIncludeName('sn_report_acl.ReportViewACLImpactUtil');
worker.setScriptIncludeMethod('insertAffectedUsersFromReport');
worker.putMethodArg('reportAffectedSysId', gg.sys_id);
worker.setBackground(true);
worker.start();
gs.print(' --> ' + worker.getProgressID());
}
}
It's configured to limit how many reports it analyzes during each run (limit). Once finished, the resulting records are created in report_view_acl_assessment_users.
By default, the assessment tool only returns five potentially affected users for each report. If you want it to return more, change the sn_report_acl.com.par_report_acl_assessment.max_affected_users system property (see the KB for more details). To find the reports where max_affected_users was reached, you can use this GlideAggregate query:
var ga = new GlideAggregate('report_view_acl_assessment_users');
ga.addAggregate('COUNT', 'report_view_acl_assessment');
ga.addHaving('COUNT', 'report_view_acl_assessment', '>', '9');
ga.query();
while (ga.next())
gs.print(ga.getDisplayValue('report_view_acl_assessment'));
https://www.servicenow.com/community/platform-analytics-articles/report-view-acl-analysis/ta-p/2300316