- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2019 11:27 AM
Hey everyone,
So I was recently tasked with sharing 400+ reports created by 1 individual amongst 3 users. I am fairly new to service now and I am not too familiar with sharing reports or how to go about this. I am aware that you can share users 1 by 1, however with 400+ reports that could take a long time. I was hoping that I could use a script using a gliderecord that queries all of the reports that I am looking for and then being able to assign each users sysid to all reports that fit the query. If there are any other suggested ways to go about this I would really appreciate the help. I also have checked the article "Bulk sharing own reports" with no luck.
Thank you all,
Wilson
Solved! Go to Solution.
- Labels:
-
Analytics and Reports
-
Best Practices
- 8,453 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2019 07:15 AM
Thank you for the quick reply!
I played around with that code and found that the array wasn't working for some reason so I hard coded the 3 users and it worked fine. When I created a query for all the records I was looking for, I simply created 3 separate records within the sys_report_users_groups table that contained the user_id of each person and the report_id as the sys_id belonging to the sys_report that we are querying!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2019 02:00 PM
When you share report with user, record is created in sys_report_users_groups table.
You can write below fix script to share multiple reports with 3 users
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2019 02:33 PM
Please use below fix script to share multiple reports with multiple users
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();
}
}
Please run this script first in your NON-prod instance to verify results and then you can run in PROD.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2019 07:15 AM
Thank you for the quick reply!
I played around with that code and found that the array wasn't working for some reason so I hard coded the 3 users and it worked fine. When I created a query for all the records I was looking for, I simply created 3 separate records within the sys_report_users_groups table that contained the user_id of each person and the report_id as the sys_id belonging to the sys_report that we are querying!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2020 05:14 AM
Hi, I had to change the code for Orlance version to:
var list = "59e8d7b8db5f5f00aee4b5ca689619b0"; //user sys_id
var arr = list.split(",");
for(i=0;i<arr[i].length;i++){
var rep = new GlideRecord('sys_report');
rep.addEncodedQuery('titleSTARTSWITHo365');
rep.query();
while(rep.next()){
var usr = new GlideRecord('sys_report_users_groups');
usr.initilize();
usr.user_id = arr[i];
usr.report_id = rep.sys_id;
usr.insert();
}
}
Br, David