How to share bulk reports to groups?

User329467
Tera Expert

Hi,

I have a requirement to share bulk reports to groups. Is it possible with fix script? or?

How to achieve this?

Thanks,

Priyatham.

1 ACCEPTED SOLUTION

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.

View solution in original post

9 REPLIES 9

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!

Great to know but did you mistakenly mark your answer as correct. Seemed responses helped but you got your answer marked correct.

Oops, that's by mistake.

Hey Jaspal Singh. I know this is an old post, but maybe you can help me out. Where do I put in the group sys ID that I want to share it with. When looking at your script I see that it just can have a limit of 10. Any help would be appreicated. Thank you!

Adam Stout
ServiceNow Employee
ServiceNow Employee