Notification to group manager's manager when group manager is about to leave the organization
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 08:42 PM
Hi All,
Greetings!
We are planning to trigger a notification to current group manager's manager when current group manager leaves in 15 days and 7 days. We have the Last working date field in the sys_user table that we can utilized.
I would like to know your thought to understand how we can trigger a notification for each group manager's manager. Possibly as part of a scheduled job or a flow. Appreciate your thought and let me know if you already have such a function.
Thanks,
Pj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 09:13 PM - edited 03-18-2024 09:15 PM
Hi @pawan2 ,
Create business rule on sys_user table and select active changes to false condition
var gr = new GlideRecord('sys_user_group');
gr.addEncodedQuery('active=true^manager.active=false');
gr.query();
if(gr.next()){
if()gr.manager==true){
gs.eventQueue("manager.left",gr,gr.manager.manager, gr.manager);//replace with you field names
}
}
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 10:02 PM
You can write schedule job and can trigger the notification based on requirement, below is the sample code you can you it:
// Query for group managers whose last working date is within 15 days and 7 days
var groupManagerGr = new GlideRecord('sys_user');
groupManagerGr.addQuery('active', true); // Only active users
groupManagerGr.addQuery('manager', '!=', ''); // Users who have a manager
groupManagerGr.addQuery('user_type', '!=', 'service_account'); // Exclude service accounts
groupManagerGr.addQuery('sys_user_group', 'ISNOTEMPTY'); // Users belonging to a group
groupManagerGr.addQuery('sys_user_role', '=', 'admin'); // Assuming 'admin' role signifies group manager, adjust as needed
groupManagerGr.addQuery('last_working_date', '>=', gs.daysAgoStart(15)); // Last working date within 15 days
groupManagerGr.addQuery('last_working_date', '<=', gs.daysAgoStart(7)); // Last working date within 7 days
groupManagerGr.query();
while (groupManagerGr.next()) {
var manager = groupManagerGr.manager;
// Retrieve manager's details
var managerGr = new GlideRecord('sys_user');
if (managerGr.get('sys_id', manager)) {
// Trigger notification to manager's manager using gs.eventQueue()
gs.eventQueue('notification.event', managerGr, groupManagerGr.name); // Pass necessary parameters
gs.info('Notification event queued for group manager: ' + groupManagerGr.name + ', Manager: ' + managerGr.name);
}
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 10:38 PM
Hi @pawan2 you can use flow designer and look up table and send Notification, no code is requried just use correct data pills.
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 10:13 AM
Hi All,
Thank you so much for all your responses. Let me try one by one. Much appreciated your support!
Thanks,
PJ