Add users to group using service catalog

Deepika25
Tera Contributor

I've requirement to add users to group using catalog item in service catalog. I'm new to this please help me.

2 REPLIES 2

SebastianB
Tera Guru

Hi,

I would say the easiest way would be to create an item with two variable, one has the reference to the group table and one has the reference to the user table. (and possible additional condition like is the group/user active)

 

Than create flow which gets triggered via request and just create record in the Group Member Table with the group / user information you get from the request. 

 

Add the flow in the last step to our item.

shyam34
Tera Contributor

Hi Deepika,

do you also required approvals before creating record , if so you need to follow different approach , if no approval is required Just use Runscript in the workflow and add this code 

var group = current.variables.add_group;
var user = current.variables.add_member.toString();
var array = user.split(",");

for (var i = 0; i < array.length; i++) {
	var gr_member = new GlideRecord('sys_user_grmember');
	gr_member.initialize();
	gr_member.group = group;
	gr_member.user = array[i].toString();
	gr_member.insert();
}

Please mark the response as helpful/correct, if it answers your question.