- 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-07-2023 10:54 PM
Hi @nebiata
Please use below code
var gr=new GlideRecord("sys_report");
gr.addEncodedQuery('table=sn_audit_engagement'); // Query for 450 report
gr.query();
gs.info(gr.getRowCount());
while(gr.next()){
var grp=new GlideRecord("sys_user_role");
grp.addQuery("sys_id","c1b46f9dc31302004e44dccdf3d3ae67"); // sys_id of another role
grp.query();
if(grp.next()){
var num=grp.name;
gs.info(num);
gr.roles=num;
gr.serWorkflow(false);
gr.update(); // added new role in report
}
}
Please try and mark Helpful and Correct if it really help you.
Before try to all 450 record, first try 1-2 record for checking it will update correct roles.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 05:49 AM
Kalyani,
That is a helpful script. However, when I try to run the fix script, it will replace the role. I need the report to be shared with both the ITIL role and this other role. how can I achieve this?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 05:55 AM - edited 11-08-2023 06:15 AM
Try this
var gr=new GlideRecord("sys_report");
gr.addEncodedQuery('table=sn_audit_engagement'); // Query for 450 report
gr.query();
gs.info(gr.getRowCount());
while(gr.next()){
var grp=new GlideRecord("sys_user_role");
grp.addQuery("sys_id","c1b46f9dc31302004e44dccdf3d3ae67"); // 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 06:39 AM
I tried the script you suggested and it removed itil and the function as role. Business_stakeholder is the role I want to add.
Thank you