Add users (from list collector field) to the group/s selected in a list collector field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 09:32 PM
Hi All
Can I ask how do we automate that when we select user/s (from list collector field), they will be automatically added to the group/s selected in a list collector field , after the group manager approval. Note: Using Flow Designer
Example:
List collector field name for the users: users_to_be_added
User_1, User_2, User_3
List collector field name for the groups: group_records
Help Desk, HR Group
Once the form is submitted in the portal, the group managers of Help Desk, HR Group needs to approve first, once they approve, User_1, User_2, User_3 will be automatically added on those groups.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 10:03 PM
you can iterate using For each for that list collector and then add the user to individual groups
what did you start with?
OR
you can also use custom action in flow and pass the values for both the list collectors and then use script for this
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2023 12:02 AM
Hi @ss123
You can try below steps :
Step 1: Trigger - Service Catalog
Step 2 : Action - Ask for approvals
Put your group name as per your need
Step 3 : Add flow logic - If condition
To check if Its approved
Step 4 : Look up for user records from variable list collector (Users)
In condition , use script to get the "Users" list from variable // you can use your variable name
Step 5 : Use flow login - for each
This will iterate through users which we will get from step 4
Step 6 : Look up for Group records from variable list collector (Groups)
use the script in condition
Step 7 : Use flow logic - for each
To iterate through each group
Step 7 : Use Action to create record in "sys_user_grmember" table
Use sys_id , from user & group record
Final flow should look like this
Note : for the already existing group member, you can use script to check if user is already member of group and eliminate that from list of sys_id.
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 05:33 PM
Hi @Vishal Birajdar in
Step 2 : Action - Ask for approvals
Put your group name as per your need
The approval from the group managers are not manually added in the flow, the groups are added by the requesters. So the group manager approval/s should be dynamic. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 10:03 PM
Hi @ss123
1. You can add on "Look up records" ('sys_user' table)action before "Ask for approval" activity with script condition
2. Condition Script :
Here will will get the group managers sys_id form list collector (groups)
var groups = fd_data.trigger.request_item.variables.groups;
var managerArray=[];
var grGroups = new GlideRecord('sys_user_group');
grGroups.addEncodedQuery('sys_idIN' + groups);
grGroups.query();
while(grGroups.next()){
//get managers
managerArray.push(grGroups.getValue('manager'));
}
var managers = managerArray.join(',');
//return the sys_id of managers to lookup records
return 'sys_idIN' + managers;
3. Update the ask for approval activity
Drag n drop the user records from 1 look up record activity.
Final flow be like :
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates