Add sn_internal roles in bulk to reports

Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 12:44 AM
Hi Team,
We want to assign "sn_internal" roles and remove "public" roles in bulk to reports.
Please suggest.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 12:50 AM
Use this script :-
var gr = new GlideRecord('sys_report'); gr.query(); while (gr.next()) { var roles = gr.roles.toString().split(','); // Remove 'public' role if present var index = roles.indexOf('public'); if (index > -1) { roles.splice(index, 1); } // Add 'sn_internal' role if not already present if (roles.indexOf('sn_internal') === -1) { roles.push('sn_internal'); } gr.roles = roles.join(','); gr.update();
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 12:54 AM
Hi @Community Alums ,
You can do that via background script checking the reports which have role as public. "roles" is the backend name of roles fields on report. Attaching the script for your reference.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P