- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2022 11:41 PM
Hi All
I have multiple groups and multiple users when user raise request for add into some X two groups, how we write a script in workflow.
how to automate assign user into group through catalog item.
Regard,
Tharun
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2022 03:04 AM
Hey Tharun,
Update script as below it is working now
var groupsArray = [];
var usersArray = [];
var users = current.variables.user_to_add; //give users list collector variable name
usersArray = users.toString().split(',');
var groups = current.variables.group; //give groups list collector variable name
groupsArray = groups.toString().split(',');
for(var i=0; i<groupsArray.length; i++)
{
for(var j=0; j<usersArray.length; j++)
{
var gr = new GlideRecord('sys_user_grmember');
gr.initialize();
gr.user = usersArray[j];
gr.group = groupsArray[i];
gr.insert();
}
}
Mark as correct and helpful if it solved your query.
Regards,
Sumanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2022 03:04 AM
Hey Tharun,
Update script as below it is working now
var groupsArray = [];
var usersArray = [];
var users = current.variables.user_to_add; //give users list collector variable name
usersArray = users.toString().split(',');
var groups = current.variables.group; //give groups list collector variable name
groupsArray = groups.toString().split(',');
for(var i=0; i<groupsArray.length; i++)
{
for(var j=0; j<usersArray.length; j++)
{
var gr = new GlideRecord('sys_user_grmember');
gr.initialize();
gr.user = usersArray[j];
gr.group = groupsArray[i];
gr.insert();
}
}
Mark as correct and helpful if it solved your query.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2022 03:30 AM
Hi Sumanth,
Thanks for your support. working fine now
Regards,
Tharun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2022 03:35 AM
Hi Sumanth,
Can you please check below question
Regards,
Tharun