Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Sharing Multiple Reports at Once

Darrion Burges1
Mega Expert

Hello All, 

I am a Reporting administrator, and I was hoping someone could give me best-practice suggestions for sharing multiple reports at once. 

- For example, if my team makes a dashboard with several tabs of reports, is there any way to pick all the reports on that dashboard and share them with a single person (or group) to speed up the process? As it currently stands, I need to have my admins share each individual reports whenever a client wants to add a user to their dashboard. 

We have admin rights in a lower environment so we would be able to write a script and push it. I imagine it would have something to do with the sharing related list on each report record, but I have not seen any implementations for sharing multiple reports at once. 

 

Thank you as always for your time and expertise. 

1 ACCEPTED SOLUTION

Saurav Maiti
Mega Expert

Hi,

 

Use this code in fixscript 

 

var list = "62826bf03710200044e0bfc8bcbe5df1,a8f98bb0eb32010045e1a5115206fe3a";// users sys_id list to whom you want to share report
var arr = list.split(",");
for(i=0;i<arr[i];i++){
	var rep = new GlideRecord('sys_report');
	rep.addEncodedQuery('title=Cost Plan Break Down');// add your encoded query to find multiple reports
	rep.query();
	while(rep.next()){
		
		var usr = new GlideRecord('sys_report_users_groups');
		usr.initilize();
		usr.user = arr[i];
		usr.report_id = rep.sys_id;
		usr.insert();
		
	}
}

View solution in original post

1 REPLY 1

Saurav Maiti
Mega Expert

Hi,

 

Use this code in fixscript 

 

var list = "62826bf03710200044e0bfc8bcbe5df1,a8f98bb0eb32010045e1a5115206fe3a";// users sys_id list to whom you want to share report
var arr = list.split(",");
for(i=0;i<arr[i];i++){
	var rep = new GlideRecord('sys_report');
	rep.addEncodedQuery('title=Cost Plan Break Down');// add your encoded query to find multiple reports
	rep.query();
	while(rep.next()){
		
		var usr = new GlideRecord('sys_report_users_groups');
		usr.initilize();
		usr.user = arr[i];
		usr.report_id = rep.sys_id;
		usr.insert();
		
	}
}