Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Scheduled Jobs/Unpublish Public Reports/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Scheduled Job to query the report table for any reports that are Published or roles are set to Public and remove the public role from report.
12 changes: 12 additions & 0 deletions Scheduled Jobs/Unpublish Public Reports/UnpublishReports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var pubReport = new GlideRecord('sys_report');
pubReport.addQuery('is_published=true^ORroles=public');
pubReport.query();
while(pubReport.next()) {
//Obtain current roles report is shared with
var removePublic = pubReport.roles;
//Remove public role from string
removePublic = removePublic.replace(/public/g, '');
//Set report roles to new string value. Wihtout public role, report will auto unpublish
pubReport.roles.setValue(removePublic);
pubReport.update();
}