How to assign a role to all users

DevtoSME
Giga Guru

We have created a module for all employees to submit their updated resumes to. In order for all employees to view this module I need to create a role for the module and then assigned it to all employees (197)

 

Should i create a role and add it to a group or is only a role needed.

Also

 

What is the best way to distribute the role to all employees (not manually) 

2 ACCEPTED SOLUTIONS

You can run the below script in System Definition > Scripts - Background

 

var grUser = new GlideRecord("sys_user");
grUser.addActiveQuery(); // Get only active users
grUser.query();
while(grUser.next()){
	var grMember = new GlideRecord('sys_user_grmember');
	grMember.initialize();
	grMember.group = "sys_id of the group created";
	grMember.user = grUser.sys_id;
	grMember.insert();
}

 

Thank you,
Palani

View solution in original post

ok,

im trying it out now

 

View solution in original post

5 REPLIES 5

palanikumar
Mega Sage

Hi,

It is always advised to assign the role to Group. And then add users as member of the Group.

 

Thank you,

Palani

Thank you,
Palani

ok so with that being said what is the best way to solve this solution to adding the all the users to the group created

You can run the below script in System Definition > Scripts - Background

 

var grUser = new GlideRecord("sys_user");
grUser.addActiveQuery(); // Get only active users
grUser.query();
while(grUser.next()){
	var grMember = new GlideRecord('sys_user_grmember');
	grMember.initialize();
	grMember.group = "sys_id of the group created";
	grMember.user = grUser.sys_id;
	grMember.insert();
}

 

Thank you,
Palani

ok,

im trying it out now