- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 12:34 PM
Currently, about 450 reports are shared with users with itil role. I have a requirement to add an additional role so those reports will be shared with the user who has itil and this additional role.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 07:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 06:48 AM
I just tried and it seems to work for me,
Can you show your script you are running.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 07:03 AM
This is what I used. Let me know.
var gr=new GlideRecord("sys_report");
gr.addEncodedQuery('roles=itil'); // Query for 450 report
gr.query();
gs.info(gr.getRowCount());
while(gr.next()){
var grp=new GlideRecord("sys_user_role");
grp.addQuery("sys_id","3be5d3d1b7103300dff9fa13ee11a987"); // sys_id of another role
grp.query();
if(grp.next()){
var num=grp.name;
gs.info(num);
gr.roles=gr.roles.toString()+','+num;
gr.serWorkflow(false);
gr.update(); // added new role in report
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 07:09 AM
It works for me,
See this is the script i ran
And result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 07:25 AM
I am not sure what happened on my first trial but works now.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 07:29 AM
Cool, happy to help