Add sn_internal roles in bulk to reports

Community Alums
Not applicable

Hi Team,

 

We want to assign "sn_internal" roles and remove "public" roles in bulk to reports.

 

Please suggest.

2 REPLIES 2

akanksha1pa
Tera Expert

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();
 

pavani_paluri
Giga Guru

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