remove inactive users from assignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 05:44 AM
Hi All,
1. I have a requiremnet to remove users from multiple assignment groups(10) when active is false in user table .
2. and also remove the users from these 10 assignment groups when users whose department code is not 1008. and send notification that users are removed from assignment group . I wnt to use schdeule job .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 05:54 AM
Hi Roshani,
1. I have a requiremnet to remove users from multiple assignment groups(10) when active is false in user table . -> You can create BR on sys_user table when active changes to false and you can remove that user from group by gliderecording on group member table.
2. Remove the users from these 10 assignment groups when users whose department code is not 1008. and send notification that users are removed from assignment group -> You can fulfil this also using BR after update by checking if current user department code is not 1008 and use the event to trigger the notification.
Regards,
Pradeep Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 06:10 AM
Hi
For the 1st point..
Create on after business rule and follow like below.
In advance write the below script
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', current.sys_id);
gr.query();
while (gr.next()) {
gr.deleteRecord();
}
})(current, previous);
2. For the 2nd point follow like below
I hope it's a one time activity..so create schedule job and run once..
var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('country!=1008');
gr.query();
while(gr.next())
{
var gr1 = new GlideRecord('sys_user_grmember');
gr1.addQuery('user', gr.sys_id);
gr1.query();
while (gr1.next()) {
gr1.deleteRecord();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 06:13 AM
Hi
For the 1st point..
Create on after business rule and follow like below.
In advance write the below script
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', current.sys_id);
gr.query();
while (gr.next()) {
gr.deleteRecord();
}
})(current, previous);
2. For the 2nd point follow like below
I hope it's a one time activity..so create schedule job and run once..
var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('country!=1008');
gr.query();
while(gr.next())
{
var gr1 = new GlideRecord('sys_user_grmember');
gr1.addQuery('user', gr.sys_id);
gr1.query();
while (gr1.next()) {
gr1.deleteRecord();
}
}