How to Assign one specific role to all ITIL users?

Shiva prasad t
Tera Guru

I want to add one specific role to all ITIL users. 

5 REPLIES 5

newhand
Mega Sage

@Shiva prasad t 

Create a group which contains all the ITIL users,

then assign the role to group.

 

It is not suggested to assign roles to users directly.

Please mark my answer as correct and helpful based on Impact.

Ankita19
Tera Guru
Tera Guru

Directly assigning a role to a person is not a best practice.

You should create a new group and provide the new role to that group.

After creating a new group, edit group members and add filter -  roles is ITIL.

Then add the members into group.

Sonali Nimbalk1
Giga Guru

@Shiva prasad t 

 

Try the below code in the background script:

var gr = new GlideRecord("sys_user");
gr.addEncodedQuery('roles=<sys_id of the role ITIL>');
gr.query();
while(gr.next()) {
	var role = new GlideRecord('sys_user_has_role')
	role.addQuery('user',gr.sys_id);
	role.addQuery('role', '<sys_id of the new role ITIL >');
	role.query();
	if(!role.next())
		{
			role.initialize();
			role.user = gr.sys_id;
			role.role = "<sys_id of the new role added>";
			role.insert();
		}


}

 

Please hit like and mark my response as correct if that helps.

Abhinandan Bhan
Tera Expert

Go to "User Administrtion > Roles" in application Menu.(1.png)

 

Search and open ITIL role from the list.

And add the role you want to the Contains Role Section by using Edit UI action in the section.(2.png)