Automatic removal of non active users from groups/roles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 12:36 AM
Hi All,
I need to implement a business rule on insert and update of users, which will check if the Active checkbox is true or false.
If it’s false, it means that the user is inactive and therefore he should be removed from all the groups and all the roles.
Also, I need to create a warning popup which will show when we try to Save a user profile, when we have made it inactive. This will prevent us from accidentally inactivating a user.
The text should be: Are you sure you want to deactivate this user? Click OK to proceed of Cancel to go back
And then we should have OK and Cancel buttons.
Could any one can please let me know and do the needful.
Thanks & Regards,
Sireesha
- Labels:
-
Script Debugger
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 08:27 PM
Please mark my response as correct and helpful to close the thread if it helped.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 12:44 AM
Hi,
If I am understanding correctly you have two different Requirement.
1. BR on insert /update of user for active true check-- Here you can use on submit client script
2. Removal of inactive users from all groups.
Is this correct understanding.
On Submit client script
function onSubmit() {
var userActive = g_form.getValue('active');
if (userActive=='false') {
return confirm('Are you sure you want to deactivate this user?');
}
}
Use following script in After BR
userInactiveRemoveGroups();
function userInactiveRemoveGroups() {
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user','current.sys_id');
gr.query();
while (gr.next()) {
gr.deleteRecord();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 02:59 AM
Hi,
I need to create a warning popup which will show when we try to Save a user profile, when we have made it inactive. This will prevent us from accidentally inactivating a user.
-- you can use onSubmit() client script suggested by others.
For removing inactive user's role and group membership use Flow Designer