I want to add users in group from Workflow

Taaha M
Tera Contributor

My requirement is to add Users in group which they have selected in Catalog form field.

Once if a user select 'Add to group-A' choice of field 'Select group to Add' , I should automatically add the user to the group.
How can I do this using Workflow?

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Taaha M 

 

https://www.servicenow.com/community/itsm-forum/how-to-add-user-to-group-sys-user-group-using-flow-d...

 

https://www.servicenow.com/community/developer-blog/mini-lab-workflows-add-users-to-groups-service-c...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Anand Kumar P
Giga Patron
Giga Patron

Hi @Taaha M ,

You can Add Run Script Activity in your flow and add below script

AnandKumarP_0-1733384309593.png

 

 

 

 

 

var groups = current.variables.group_name.toString();
var user = current.variables.user_list.toString().split(',');

for (i = 0; i < user.length; i++) {

	var newUser = new GlideRecord('sys_user_grmember');
	newUser.initialize();
	newUser.group = groups;
	newUser.user = user[i];
	newUser.insert();
}
 

 

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

Jagadish Sanadi
Kilo Sage

Hello Taaha,

 

Looks like you need to add user to Group selected. Please confirm your ask