- 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-21-2022 11:46 PM
Why are you not using Flow designer, I think that will be much easier and low code way of handling this.
If still looking for workflow, you can follow below article:
How to add multiple users to multiple groups through catalog item.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2022 03:18 AM
Hello Aman,
we are not using the flow designer, i am new into flow designer.
I could see above script is Flow designer script. can please share the workflow script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2022 06:02 AM
Below link is used in BR, will need a lil modification to be run into Run script:
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2022 03:30 AM
Hi,
can you share what script did you start with?
Is user variable a list collector and group variable a reference type?
unless you share what type of variables are those we cannot help
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader