- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2024 01:25 AM
Hi,
I have to remove roles and group when user profile is not active.
Can anyone please help me to achieve that.
Regards,
Nivedita
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2024 01:39 AM
Hi @niveditakumari roles are always tied to group. There are 2 ways to do this
1. using flow designer , no code required, trigger will be when active is false
2. using after update BR,
Cond: active is false
script:
var user = new GlideRecord('sys_user');
user.addQuery('active', false);
user.query();
while (user.next()) {
// Remove groups
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('user.sys_id', user.sys_id);
grp.query();
while (grp.next()) {
grp.deleteMultiple();
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2024 01:31 AM
@niveditakumari , here is the Solution , First Try in Lower Instance
Regards,
Shyamkumar
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2024 01:35 AM
Hello @niveditakumari
You can check below threads which satisfies your requirement.
if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
CB

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2024 01:39 AM
Hi @niveditakumari roles are always tied to group. There are 2 ways to do this
1. using flow designer , no code required, trigger will be when active is false
2. using after update BR,
Cond: active is false
script:
var user = new GlideRecord('sys_user');
user.addQuery('active', false);
user.query();
while (user.next()) {
// Remove groups
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('user.sys_id', user.sys_id);
grp.query();
while (grp.next()) {
grp.deleteMultiple();
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 02:08 AM