Skip to content

Commit d4b8154

Browse files
Bulk Share - Reports (#1771)
* script.js * readme.md * readme.md * script.js
1 parent dc23375 commit d4b8154

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
How often we come across cases where report created by one user needs to be shared with multiple users. We can use the 'Share' option but will be time consuming.
2+
Imagine being able to do it via script by just passing sys_id of users.
3+
Use this script to share report in bulk by executing it as Background script
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var list = "4b6c76e3dbcfaf0000ec7abe3b961912,9e67d6d1db736300d43c54e848961934"; //pass user sys_id here who needs access to reports
2+
var arr = list.split(",");
3+
for(i=0;i<arr[i].length;i++){
4+
var rep = new GlideRecord('sys_report');
5+
rep.addEncodedQuery('sys_created_by=abc@gmail.com');//replace with appropriate user mail who creaed the report
6+
rep.query();
7+
if(rep.next()){
8+
var usr = new GlideRecord('sys_report_users_groups');
9+
usr.initilize();
10+
usr.user_id = arr[i];
11+
usr.report_id = rep.sys_id;
12+
usr.insert();
13+
}
14+
}

0 commit comments

Comments
 (0)