- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2020 05:17 AM
Hi,
I have a requirement to share bulk reports to groups. Is it possible with fix script? or?
How to achieve this?
Thanks,
Priyatham.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2020 06:05 AM
Here you go.
var groupsare=new GlideRecord('sys_user_group');
groupsare.addEncodedQuery('active=true');//Pass desired users query here
//groupsare.setLimit(10); //uncomment to check for 10 records
groupsare.query();
gs.print(groupsare.getRowCount());
while(groupsare.next())
{
var sharereport=new GlideRecord('sys_report_users_groups');
sharereport.initialize();
sharereport.report_id.setDisplayValue('TimeCard Trend'); //Pass report name
sharereport.group_id=groupsare.sys_id;
sharereport.insert();
gs.print(sharereport.getRowCount());
}
If any of above comments helped you can kindly mark it as Helpful & also get the thread closed once you got things working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2020 06:29 AM
This worked for me to share report to groups acc to my requirement.
var groupshare = new GlideRecord('sys_user_group');
groupshare.addEncodedQuery('active=true');
groupshare.query();
var rep = new GlideRecord('sys_report');
rep.addEncodedQuery('sys_created_by=admin');
rep.query();
while (groupshare.next() && rep.next()) {
var sharereport = new GlideRecord('sys_report_users_groups');
sharereport.initialize();
sharereport.report_id = rep.sys_id;
sharereport.group_id = groupshare.sys_id;
sharereport.insert();
}
Thanks for the help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2020 06:34 AM
Great to know but did you mistakenly mark your answer as correct. Seemed responses helped but you got your answer marked correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2020 11:09 PM
Oops, that's by mistake.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2021 01:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2020 08:53 AM
Why does a scheduled report not work?
https://docs.servicenow.com/csh?version=latest&topicname=t_ScheduleAReport