- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2020 04:37 AM
Hello community,
How to unpublish a report using script?
I tried switching the is_published to True but if I go to the report then and check if it was published, it wont be.
So it has to be something else that I'm not aware of.
Would appreciate pointers/tips.
Thanks in advance!
Solved! Go to Solution.
- Labels:
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2020 05:18 AM
Hi, I ended up raising a HI Case to ask SN about this and this is what they responded. (basically cant do it with script)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2020 06:17 AM
Hi,
the script may not be reliable as we are not sure on how ServiceNow handles it in backend
So rely on manual step
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2020 05:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2020 05:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2020 05:11 AM
Hi,
Yes I know about this way, but question was more for doing it within a script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2021 01:05 PM
Published reports are available to the role 'public'. You need to remove that role to unpublish a report.
Here's what I did, with an output of URLs that you can go test and verify they are no longer publicly accessible:
function publicReports() {
var reports = [];
var grReport = new GlideRecord('sys_report');
grReport.addEncodedQuery('roles=public');
grReport.query();
while (grReport.next()) {
reports.push(grReport.title + ': https://{INSTANCE_INFO}.service-now.com/sys_report_display.do?sysparm_report_id=' + grReport.sys_id);
grReport.roles = grReport.roles.replace('public', '');
grReport.is_published = false;
grReport.update();
}
return reports;
}
var goGetEm = publicReports();
goGetEm;