- 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-06-2020 11:30 AM
Hey Michael,
That field is on the HR Profile, which is sn_hr_core_profile.
More details are on my actual post for this if you'd like to lend a hand.
Updating a users account and assignment group when termed
I greatly appreciate it!!
-Rob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 08:40 AM
Hi Raghu,
It is not recommended or common practice to remove users from ServiceNow (sys_user table) as and when users are inactivated.
My recommendation is to set a business rule up that performs the functionality you require (removing inactive users from groups, but importantly not remove the users from the system) when the user is inactivated.
Using a business rule will ensure the data is kept up to date moving forward.
Whilst a schedule job will remove users from groups, this is a retrospective job. I'd therefore recommend implementing the business rule as described above as well as running the scheduled job once.
Make sense?
Thanks,Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2019 06:57 AM
Hello Raghu, Chuck
I know this is an old post which has already been marked as answered however, I have a question. I am looking to clear inactive users too from groups however, we are importing the feed from the active directory as well. So with this solution, we are just removing the user from a group in ServiceNow however, when the auto-feed importer runs, all the changes we did are reversed and inactive users are back. I am not sure if you are using active directory but if you can suggest a possible solution to this problem, that would be great.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2019 07:42 AM
Thank you for the response. You are correct, we are simply changing the information on the ServiceNow instance. if you are importing from another source, you will need to change the information on that source. To do that with Active Directory, you could create an Orchestration workflow or use IntegrationHub with Flow Designer to trigger on the sys_user_grmember record and send the appropriate commands to Active Directory automatically.
Keep in mind that this level of automation using Orchestration or IntegrationHub may/will impact your licensing. Talk to your account team.