- 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 09:10 AM
I would go with a scheduled job. Business rule is only going to trigger when the record is created/changed/etc. If you miss that 28 day window, there's no action taken. A scheduled job that runs nightly can help with that.
The question is... where are you tracking the time the record was set to inactive? It's one thing to check the box, but relying on sys_updated_on (date/time field) for your 28 day counter could provide incorrect results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2017 08:54 AM
Thanks chuck, we have one date field to store inactive date of user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2017 09:09 AM
This script is working fine chuck lot of thanks for this

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2020 10:44 AM
Hey
I know this post is old, but I am trying to accomplish something just like this using a scheduled job.
I used this as of right now - which worked, however it removed ALL members from the group. I only want to remove the person based on a custom field 'u_termed_in_workday'.
Are you able to help?
u_termed_in_workday();
function u_termed_in_workday() {
var gm = new GlideRecord('sys_user_grmember');
gm.addQuery('u_termed_in_workday', true);
gm.query();
while (gm.next()) {
gm.deleteRecord();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2020 11:25 AM
Is u_termed_in_workday a field on the sys_user_grmember table or sys_user? If sys_user, try using user.u_termed_in_workday