Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2022 03:03 AM
Requirement is manager of a particular group should be able to add multiple users to the selected group or remove multiple users from the selected group using catalog item.
when manager submits the request, users in "Add members to group" should be added and
users in "Remove members from group" should be removed from the group.
what should be the script in workflow("run Script").
Solved! Go to Solution.
Labels:
- Labels:
-
Service Catalog
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2022 05:39 AM
Hi,
update as this and test
var usersToAdd = current.variables.add_users; // give correct variable name here
var usersToRemove = current.variables.remove_users; // give correct variable name here
var group = current.variables.group; // give correct variable name here
var rec = new GlideRecord('sys_user_grmember');
rec.addQuery("group", group);
rec.addQuery("user", "IN", usersToRemove.toString());
rec.query();
rec.deleteMultiple();
var arr = usersToAdd.toString().split(',');
for(var i=0;i<arr.length;i++){
var addRec = new GlideRecord('sys_user_grmember');
addRec.addQuery("user", arr[i]);
addRec.addQuery("group", group);
addRec.query();
if(!addRec.hasNext()){
addRec.initialize();
addRec.user = arr[i];
addRec.group = group;
addRec.insert();
}
}
Regards
Ankur
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
25 REPLIES 25
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2022 03:55 AM