- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 05:43 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 05:47 AM
Hi Raghu,
How about something like this... Note this is not tested... Always backup your data (e.g. export the sys_user_grmember table to XML) before testing with the deleteRecord operation.
(function () {
var gm = new GlideRecord('sys_user_grmember');
gm.addQuery('user.active', false);
gm.query();
while (gm.next()) {
gm.deleteRecord();
}
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 05:47 AM
Hi Raghu,
How about something like this... Note this is not tested... Always backup your data (e.g. export the sys_user_grmember table to XML) before testing with the deleteRecord operation.
(function () {
var gm = new GlideRecord('sys_user_grmember');
gm.addQuery('user.active', false);
gm.query();
while (gm.next()) {
gm.deleteRecord();
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 06:03 AM
Thanks Chuk
I will test this code and once I done I will let you know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 07:28 AM
Hi Raghu,
Adding to Chuck's response and script which should perform the functionality you require, you should also consider adding an on 'after' business rule on the sys_user table to remove the user that's just been inactivated from any groups.
This will ensure that the data is kept up to date moving forward and not only when you run the (retrospective) schedule job.
Thanks,
Robbie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 07:51 AM
Excellent point Robbie. I just made that recommendation to someone else yesterday. How soon I forget... getting old I guess.