- 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 04:58 AM
Hi,
for bulk update you can use script
var gr = new GlideRecord('sys_report');
gr.addQuery('name', 'IN' ,'report1,report2'); // give report names as comma separated
gr.query();
while(gr.next()){
gr.is_published = false;
gr.setWorkflow(false);
gr.update();
}
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-16-2020 05:09 AM
As I replied into Mohids chain, is this issue on the Sharing tab happening because I did not disable the workflow?
Also had to disable the OOTB business rule "Report roles updated - is_publish field" to even be able to change it by script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2020 05:38 AM
Hi,
As mentioned in my script you should be using setWorkflow(false) to avoid triggering any BR
Don't disable OOB BR
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-16-2020 05:49 AM
Thanks Ankur,
One last question.
Even though it updates it on the report form and I can see in the XML is_published is set on false, when I go to view the report and open the sharing tab it still says "Unpublish" like it's still published.
Why is that? Which one reflects the actual state of the report? If users decide they want this report they might be confused when getting an email about a report that was unpublished, but on the Sharing tab it looks like published still.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2020 06:07 AM
Hi Harl,
In that case you should use the manual way I guess so that it should not show 'unpublish' option for unpublished reports.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)