- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2015 09:44 AM
When a user goes inactive we need to check if that user was a manager of a group or if that user was a member of a group. If the user is a member of a group we will remove them from that group. If they were a manager of that group we need to replace that user with their manager and notify the manager that they have been assigned the group manager.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2015 10:48 AM
A business rule on sys_user that says:
before Insert
condition current.active.changesTo('false')
var group = new GlideRecord('sys_user_group');
group.addQuery('manager', current.sys_id);
group.query();
while(group.next()){
group.manager = current.manager;
group.update();
gs.eventQueue('group.manager.changed', group, group.manager, current.name);
}
var grmember = new GlideRecord('sys_user_grmember');
grmember.addQuery('user', current.sys_id);
grmember.query();
while(grmember.next()){
grmember.deleteRecord();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2015 10:48 AM
A business rule on sys_user that says:
before Insert
condition current.active.changesTo('false')
var group = new GlideRecord('sys_user_group');
group.addQuery('manager', current.sys_id);
group.query();
while(group.next()){
group.manager = current.manager;
group.update();
gs.eventQueue('group.manager.changed', group, group.manager, current.name);
}
var grmember = new GlideRecord('sys_user_grmember');
grmember.addQuery('user', current.sys_id);
grmember.query();
while(grmember.next()){
grmember.deleteRecord();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2015 10:50 AM
Then register the event 'group.manager.changed' in Event Registry.
Then create a notification that fires when this event fires. Add the text to the notification that tells the manager what group was changed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2015 11:01 AM
Thanks Mike Allen, that helped a lot.
I have another question which is similar to this type.
Q1) If user goes inactive we need to see if that user was assigned any active tasks, if so we will need to reassign those tasks to the users manager and notify the manager that they are being assigned those tasks because the user has become inactive.
Q2) If user goes inactive and has approvals assigned to them we will want to notify the requested for that the approver has become inactive and the request will auto cancel within 3 days.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2015 12:20 PM
Similar query:
var task = new GlideRecord('task');
task.addActiveQuery();
task.addQuery('assigned_to', current.sys_id);
task.query();
while(task.next()){
task.assigned_to = current.manager;
gs.eventQueue('task.reassigned', task, current.manager, current.sys_id);
}
var approval = new GlideRecord('sysapproval_approver');
approval.addQuery('approver', current.sys_id);
approval.addQuery('state', 'requested');
approval.query();
while(approval.next()){
gs.eventQueue('approval.cancelled', approval, current.sysapproval.requested_by, current.sys_id);
}